from CvPythonExtensions import *
import CvUtil
import Popup as PyPopup
import CvScreensInterface
import sys
import PyHelpers
import CustomFunctions
PyInfo = PyHelpers.PyInfo
PyPlayer = PyHelpers.PyPlayer
gc = CyGlobalContext()
cf = CustomFunctions.CustomFunctions()

def cast(argsList):
	pCaster, eSpell = argsList
	spell = gc.getSpellInfo(eSpell)
	eval(spell.getPyResult())

def canCast(argsList):
	pCaster, eSpell = argsList
	spell = gc.getSpellInfo(eSpell)
	return eval(spell.getPyRequirement())

def effect(argsList):
	pCaster, eProm = argsList
	prom = gc.getPromotionInfo(eProm)
	eval(prom.getPyPerTurn())

def vote(argsList):
	eVote, int = argsList
	vote = gc.getVoteInfo(eVote)
	eval(vote.getPyResult())

def miscast(argsList):
	pCaster, eSpell = argsList
	spell = gc.getSpellInfo(eSpell)
	eval(spell.getPyMiscast())

def postCombatLost(argsList):
	pCaster, pOpponent = argsList
	unit = gc.getUnitInfo(pCaster.getUnitType())
	eval(unit.getPyPostCombatLost())

def postCombatWon(argsList):
	pCaster, pOpponent = argsList
	unit = gc.getUnitInfo(pCaster.getUnitType())
	eval(unit.getPyPostCombatWon())

def findClearPlot(pUnit, plot):
	BestPlot = -1
	iBestPlot = 0
	if pUnit == -1:
		iX = plot.getX()
		iY = plot.getY()
		for iiX in range(iX-1, iX+2, 1):
			for iiY in range(iY-1, iY+2, 1):
				iCurrentPlot = 0
				pPlot = CyMap().plot(iiX,iiY)
				if pPlot.getNumUnits() == 0:
					if (pPlot.isWater() == plot.isWater() and pPlot.isPeak() == False and pPlot.isCity() == False):
						iCurrentPlot = iCurrentPlot + 5
				if iCurrentPlot >= 1:
					iCurrentPlot = iCurrentPlot + CyGame().getSorenRandNum(5, "findClearPlot")
					if iCurrentPlot >= iBestPlot:
						BestPlot = pPlot
						iBestPlot = iCurrentPlot
		return BestPlot
	iX = pUnit.getX()
	iY = pUnit.getY()
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			iCurrentPlot = 0
			pPlot = CyMap().plot(iiX,iiY)
			if pPlot.getNumUnits() == 0:
				if pUnit.canMoveOrAttackInto(pPlot, False):
					iCurrentPlot = iCurrentPlot + 5
			for i in range(pPlot.getNumUnits()):
				if pPlot.getUnit(i).getOwner() == pUnit.getOwner():
					if pUnit.canMoveOrAttackInto(pPlot, False):
						iCurrentPlot = iCurrentPlot + 15
			if pPlot.isCity():
				if pPlot.getPlotCity().getOwner() == pUnit.getOwner():
					iCurrentPlot = iCurrentPlot + 50
			if (iX == iiX and iY == iiY):
				iCurrentPlot = 0
			if iCurrentPlot >= 1:
				iCurrentPlot = iCurrentPlot + CyGame().getSorenRandNum(5, "findClearPlot")
				if iCurrentPlot >= iBestPlot:
					BestPlot = pPlot
					iBestPlot = iCurrentPlot
	return BestPlot

def startWar(iPlayer, i2Player):
	iTeam = gc.getPlayer(iPlayer).getTeam()
	i2Team = gc.getPlayer(i2Player).getTeam()
	eTeam = gc.getTeam(iTeam)
	if (eTeam.isAtWar(i2Team) == False and iTeam != i2Team and eTeam.isHasMet(i2Team)):
		eTeam.declareWar(i2Team, False, WarPlanTypes.WARPLAN_LIMITED)

def postCombatExplode(pCaster, pOpponent):
	iX = pCaster.getX()
	iY = pCaster.getY()
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			if not (iiX == iX and iiY == iY):
				pPlot = CyMap().plot(iiX,iiY)
				if pPlot.isNone() == False:
					if (pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST_NEW')):
						if CyGame().getSorenRandNum(100, "Flames Spread") <= gc.getDefineINT('FLAMES_SPREAD_CHANCE'):
							pPlot.setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_SMOKE'))
					for i in range(pPlot.getNumUnits()):
						pUnit = pPlot.getUnit(i)
						pUnit.doDamage(10, 100, pCaster, gc.getInfoTypeForString('DAMAGE_FIRE'), false)

def postCombatHeal50(pCaster, pOpponent):
	if pCaster.getDamage() > 0:
		pCaster.setDamage(pCaster.getDamage() / 2, pCaster.getOwner())

def postCombatReducePopulation(pCaster, pOpponent):
	pPlot = pOpponent.plot()
	if pPlot.isCity():
		pCity = pPlot.getPlotCity()
		if pCity.getPopulation() > 1:
			pCity.changePopulation(-1)
			CyInterface().addMessage(pCity.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_POPULATION_REDUCED", ()),'',1,'Art/Interface/Buttons/Units/Angel of Death.dds',ColorTypes(7),pCity.getX(),pCity.getY(),True,True)

#Meteoric Iron
def reqBuyArmorMI(pCaster):
	if pCaster.getLevel() >= 6 and not pCaster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_METEORIC_IRON_ARMOUR')):
		pCity = pCaster.plot().getPlotCity()
		if pCity.hasBonus(gc.getInfoTypeForString('BONUS_METEORIC_IRON')):
			if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_MASTERSMITH')) > 0:
				lUnitcombats = ['UNITCOMBAT_ARCHER','UNITCOMBAT_CHARIOT','UNITCOMBAT_DIVINE','UNITCOMBAT_MELEE','UNITCOMBAT_MOUNTED','UNITCOMBAT_RECON']
				lUnitcombatTypes = [ CvUtil.findInfoTypeNum(gc.getUnitCombatInfo, gc.getNumUnitCombatInfos, item ) for item in lUnitcombats]
				if pCaster.getUnitCombatType() in lUnitcombatTypes:
					return true
	return false

def reqBuyArmorGR(pCaster):
	pPlayer = gc.getPlayer(pCaster.getOwner())
	if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DWARVES'):
		if pCaster.getLevel() >= 6 and not pCaster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_GROMRIL_ARMOUR')):
			pCity = pCaster.plot().getPlotCity()
			if pCity.hasBonus(gc.getInfoTypeForString('BONUS_METEORIC_IRON')) == true:
				if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_RUNEFORGE')) > 0:
					lUnitcombats = ['UNITCOMBAT_ARCHER','UNITCOMBAT_CHARIOT','UNITCOMBAT_DIVINE','UNITCOMBAT_MELEE','UNITCOMBAT_MOUNTED','UNITCOMBAT_RECON']
					lUnitcombatTypes = [ CvUtil.findInfoTypeNum(gc.getUnitCombatInfo, gc.getNumUnitCombatInfos, item ) for item in lUnitcombats]
					if pCaster.getUnitCombatType() in lUnitcombatTypes:
						return true
	return false
	
#Dark Magic
def reqSoulstealer(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_STOLEN_SOUL')) == false:
		for iiX in range(iX-2, iX+3, 1):
			for iiY in range(iY-2, iY+3, 1):
				pPlot = CyMap().plot(iiX,iiY)
				bEnemy = false
				bNeutral = false
				for i in range(pPlot.getNumUnits()):
					pUnit = pPlot.getUnit(i)
					if eTeam.isAtWar(pUnit.getTeam()):
						bEnemy = true
					else:
						bNeutral = true
				if (bEnemy and bNeutral == false):
					return true
	return false

def spellSoulstealer(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(50, 50, caster, gc.getInfoTypeForString('DAMAGE_DEATH'), true)
			if pUnit.isResisted(caster, gc.getInfoTypeForString('SPELL_SOUL_STEALER')) == false:
				pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_RENDED_SOUL'), True)
				caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_STOLEN_SOUL'), True)
				CyInterface().addMessage(pUnit.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_RENDED_SOUL", ()),'',1,'Art/Interface/Buttons/Spells/Darkmagic/Rended_Soul.dds',ColorTypes(7),pUnit.getX(),pUnit.getY(),True,True)
				CyInterface().addMessage(caster.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_STOLEN_SOUL", ()),'',1,'Art/Interface/Buttons/Spells/Darkmagic/Soul_Stealer.dds',ColorTypes(8),pUnit.getX(),pUnit.getY(),True,True)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_WITHER'),pBestPlot.getPoint())

def reqBlackHorror(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					return true
	return false

def spellBlackHorror(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_BLACK_HORROR'),pPlot.getPoint())
					if pUnit.isResisted(caster, gc.getInfoTypeForString('SPELL_BLACK_HORROR')) == false:
						if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HERO')) == false:
							iResist = 50 - (pUnit.baseCombatStr() * 2)
							iRnd = CyGame().getSorenRandNum(100, "Bob")
							if iRnd <= iResist:
								CyInterface().addMessage(pUnit.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_BLACK_HORROR", ()),'',1,'Art/Interface/Buttons/Spells/DarkMagic/Black_Horror.dds',ColorTypes(7),pUnit.getX(),pUnit.getY(),True,True)
								CyInterface().addMessage(caster.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_BLACK_HORROR", ()),'',1,'Art/Interface/Buttons/Spells/DarkMagic/Black_Horror.dds',ColorTypes(8),pUnit.getX(),pUnit.getY(),True,True)
								pUnit.kill(False,0)
							
def reqTorturousVision(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					return true
	return false

def spellTorturousVision(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					if pUnit.isResisted(caster, gc.getInfoTypeForString('SPELL_TORTUROUS_VISION')) == false:
						CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SCARYFACE'),pPlot.getPoint())

def reqDominion(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iResistMax = 95
	if pPlayer.isHuman() == false:
		iResistMax = 20
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if pUnit.isAlive():
					if pUnit.isDelayedDeath() == False:
						if eTeam.isAtWar(pUnit.getTeam()):
							iResist = pUnit.getResistChance(caster, gc.getInfoTypeForString('SPELL_DOMINION'))
							if iResist <= iResistMax:
								return true
	return false

def spellDominion(caster):
	iSpell = gc.getInfoTypeForString('SPELL_DOMINION')
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iResistMax = 95
	iBestValue = 0
	pBestUnit = -1
	if pPlayer.isHuman() == false:
		iResistMax = 20
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				iValue = 0
				if pUnit.isAlive():
					if pUnit.isDelayedDeath() == False:
						if eTeam.isAtWar(pUnit.getTeam()):
							iResist = pUnit.getResistChance(caster, iSpell)
							if iResist <= iResistMax:
								iValue = pUnit.baseCombatStr() * 10
								iValue = iValue + (100 - iResist)
								if iValue > iBestValue:
									iBestValue = iValue
									pBestUnit = pUnit
	if pBestUnit != -1:
		pPlot = caster.plot()
		if pBestUnit.isResisted(caster, iSpell) == false:
			CyInterface().addMessage(pBestUnit.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_DOMINION", ()),'',1,'Art/Interface/Buttons/Spells/Darkmagic/Dominion.dds',ColorTypes(7),pBestUnit.getX(),pBestUnit.getY(),True,True)
			CyInterface().addMessage(caster.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_DOMINION_ENEMY", ()),'',1,'Art/Interface/Buttons/Spells/Darkmagic/Dominion.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
			newUnit = pPlayer.initUnit(pBestUnit.getUnitType(), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
			newUnit.convert(pBestUnit)
		else:
			CyInterface().addMessage(caster.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_DOMINION_FAILED", ()),'',1,'Art/Interface/Buttons/Spells/Darkmagic/Dominion.dds',ColorTypes(7),pPlot.getX(),pPlot.getY(),True,True)
			caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MENTAL_AGONY'), True)

#Highmagic
def reqFlamesOfPhoenix(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellFlamesOfPhoenix(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(20, 65, caster, gc.getInfoTypeForString('DAMAGE_FIRE'), true)
			pUnit.doDamage(20, 65, caster, gc.getInfoTypeForString('DAMAGE_HOLY'), true)
		if (pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE')):
			if CyGame().getSorenRandNum(100, "Flames Spread") <= gc.getDefineINT('FLAMES_SPREAD_CHANCE'):
				pPlot.setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_SMOKE'))
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_PILLAR_OF_FIRE'),pBestPlot.getPoint())		

#Loren Magic		
def reqForestFury(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellForestFury(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(25, 50, caster, gc.getInfoTypeForString('DAMAGE_POISON'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_ENTANGLE'),pBestPlot.getPoint())

def reqTreesingattack(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellTreesingattack(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(20, 40, caster, gc.getInfoTypeForString('DAMAGE_PHYSICAL'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_ENTANGLE'),pBestPlot.getPoint())
		
#Amethyst Magic
def reqDarkHand(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellDarkHand(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(30, 60, caster, gc.getInfoTypeForString('DAMAGE_DEATH'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_WITHER'),pBestPlot.getPoint())
		
def reqLaniphCaress(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellLaniphCaress(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(30, 100, caster, gc.getInfoTypeForString('DAMAGE_DEATH'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_ENTROPY_SUMMON'),pBestPlot.getPoint())		

#Celestial Magic
def reqThunderbolt(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellThunderbolt(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(50, 60, caster, gc.getInfoTypeForString('DAMAGE_LIGHTNING'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SPIRITUAL_HAMMER'),pBestPlot.getPoint())

#Gold
def reqSlenderVein(caster):
	iCopper = gc.getInfoTypeForString('BONUS_COPPER')
	iSilver = gc.getInfoTypeForString('BONUS_SILVER')
	iGold = gc.getInfoTypeForString('BONUS_GOLD')
	pPlot = caster.plot()
	if pPlot.getOwner() != caster.getOwner():
		return False
	if (pPlot.getBonusType(-1) != iSilverr and pPlot.getBonusType(-1) != iGold):
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		if (pPlot.getBonusType(-1) == iGold and pPlayer.countOwnedBonuses(iGold) >= 2 and pPlayer.countOwnedBonuses(iSilver) == 0):
			return True
		elif (pPlot.getBonusType(-1) == iSilver and pPlayer.countOwnedBonuses(iSilver) >= 2 and pPlayer.countOwnedBonuses(iCopper) == 0):
			return True
		return False
	return True

def spellSlenderVein(caster):
	pPlot = caster.plot()
	iBonus = -1
	iCopper = gc.getInfoTypeForString('BONUS_COPPER')
	iSilver = gc.getInfoTypeForString('BONUS_SILVER')
	iGold = gc.getInfoTypeForString('BONUS_GOLD')
	if pPlot.getBonusType(-1) == iGold:
		iBonus = iSilver
	if pPlot.getBonusType(-1) == iSilver:
		iBonus = iCopper
	if iBonus != -1:
		pPlot.setBonusType(iBonus)

def reqTouchOfMidas(caster):
	iCopper = gc.getInfoTypeForString('BONUS_COPPER')
	iSilver = gc.getInfoTypeForString('BONUS_SILVER')
	iGold = gc.getInfoTypeForString('BONUS_GOLD')
	pPlot = caster.plot()
	if pPlot.getOwner() != caster.getOwner():
		return False
	if (pPlot.getBonusType(-1) != iCopper and pPlot.getBonusType(-1) != iSilver):
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		if (pPlot.getBonusType(-1) == iCopper and pPlayer.countOwnedBonuses(iCopper) >= 2 and pPlayer.countOwnedBonuses(iSilver) == 0):
			return True
		elif (pPlot.getBonusType(-1) == iSilver and pPlayer.countOwnedBonuses(iSilver) >= 2 and pPlayer.countOwnedBonuses(iGold) == 0):
			return True
		return False
	return True

def spellTouchOfMidas(caster):
	pPlot = caster.plot()
	iBonus = -1
	iCopper = gc.getInfoTypeForString('BONUS_COPPER')
	iSilver = gc.getInfoTypeForString('BONUS_SILVER')
	iGold = gc.getInfoTypeForString('BONUS_GOLD')
	if pPlot.getBonusType(-1) == iCopper:
		iBonus = iSilver
	if pPlot.getBonusType(-1) == iSilver:
		iBonus = iGold
	if iBonus != -1:
		pPlot.setBonusType(iBonus)

#Grey
def reqCreapingDeath(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellCreapingDeath(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(10, 10, caster, gc.getInfoTypeForString('DAMAGE_UNHOLY'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_WITHER'),pBestPlot.getPoint())

def reqMirror(caster):
	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ILLUSION')):
		return False
	return True

def spellMirror(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	newUnit = pPlayer.initUnit(caster.getUnitType(), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
	for i in range(gc.getNumPromotionInfos()):
		if gc.getPromotionInfo(i).isEquipment() == False:
			newUnit.setHasPromotion(i, caster.isHasPromotion(i))
	newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ILLUSION'), True)
	newUnit.setDamage(caster.getDamage(), caster.getOwner())
	newUnit.setLevel(caster.getLevel())
	newUnit.setExperience(caster.getExperience(), -1)
	newUnit.setDuration(1)		
		
def reqTraitor(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iResistMax = 95
	if pPlayer.isHuman() == false:
		iResistMax = 20
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if pUnit.isAlive():
					if eTeam.isAtWar(pUnit.getTeam()):
						iResist = pUnit.getResistChance(caster, gc.getInfoTypeForString('SPELL_TRAITOR_OF_TARN'))
						if iResist <= iResistMax:
							return true
	return false

def spellTraitor(caster):
	iSpell = gc.getInfoTypeForString('SPELL_TRAITOR_OF_TARN')
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iResistMax = 95
	iBestValue = 0
	pBestUnit = -1
	if pPlayer.isHuman() == false:
		iResistMax = 20
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				iValue = 0
				if pUnit.isAlive():
					if eTeam.isAtWar(pUnit.getTeam()):
						iResist = pUnit.getResistChance(caster, iSpell)
						if iResist <= iResistMax:
							iValue = pUnit.baseCombatStr() * 10
							iValue = iValue + (100 - iResist)
							if iValue > iBestValue:
								iBestValue = iValue
								pBestUnit = pUnit
	if pBestUnit != -1:
		pPlot = caster.plot()
		if pBestUnit.isResisted(caster, iSpell) == false:
			CyInterface().addMessage(pBestUnit.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_TRAITOR_OF_TARN", ()),'',1,'Art/Interface/Buttons/Spells/Ulgu/Traitor_of_Tarn.dds',ColorTypes(7),pBestUnit.getX(),pBestUnit.getY(),True,True)
			CyInterface().addMessage(caster.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_TRAITOR_OF_TARN_ENEMY", ()),'',1,'Art/Interface/Buttons/Spells/Ulgu/Traitor_of_Tarn.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
			newUnit = pPlayer.initUnit(pBestUnit.getUnitType(), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
			newUnit.convert(pBestUnit)
		else:
			CyInterface().addMessage(caster.getOwner(),true,25,CyTranslator().getText("TXT_KEY_MESSAGE_TRAITOR_OF_TARN_FAILED", ()),'',1,'Art/Interface/Buttons/Spells/Ulgu/Traitor_of_Tarn.dds',ColorTypes(7),pPlot.getX(),pPlot.getY(),True,True)
			caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_GREY3'), false)

#Jade
def reqEarthsGrasp(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellEarthsGrasp(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(30, 60, caster, gc.getInfoTypeForString('DAMAGE_PHYSICAL'))
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_CRUSH'),pBestPlot.getPoint())

def reqFatherofThorn(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellFatherofThorn(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(20, 40, caster, gc.getInfoTypeForString('DAMAGE_POISON'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_ENTANGLE'),pBestPlot.getPoint())

def reqLandLord(caster):
	pPlot = caster.plot()
	if pPlot.getOwner() != caster.getOwner():
		return False
	if pPlot.isWater():
		return false
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_GRASS'):
		return False
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_SCORCHED_EARTH'):
		return False
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_BONEPLAINS'):
		return False
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_CHAOS_WASTE'):
		return False
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_MARSH'):
		return False
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_LAVA'):
		return False	
	return True

def spellLandLord(caster):
	pPlot = caster.plot()
	if(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_SNOW')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_TUNDRA'),True,True)
	elif(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_TUNDRA')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_PLAINS'),True,True)
	elif(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_DESERT')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_PLAINS'),True,True)
	elif(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_PLAINS')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_GRASS'),True,True)		
		
def reqMasterofWood(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellMasterofWood(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(30, 60, caster, gc.getInfoTypeForString('DAMAGE_POISON'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_ENTANGLE'),pBestPlot.getPoint())		
		
def reqMistressoftheMarsh(caster):
	pPlot = caster.plot()
	if pPlot.getOwner() != caster.getOwner():
		return False
	if pPlot.isWater():
		return false
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_BURNING_SANDS'):
		return False
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_HILL'):
		return False
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_BROKEN_LANDS'):
		return False
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_FIELDS_OF_PERDITION'):
		return False
	return True

def spellMistressoftheMarsh(caster):
	pPlot = caster.plot()
	if(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_SNOW')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_TUNDRA'),True,True)
	elif(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_TUNDRA')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_MARSH'),True,True)
	elif(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_DESERT')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_PLAINS'),True,True)
	elif(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_PLAINS')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_MARSH'),True,True)
	elif(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_GRASS')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_MARSH'),True,True)
	elif(pPlot.getTerrainType()==gc.getInfoTypeForString('TERRAIN_MARSH')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_GRASS'),True,True)

#Light Magic
def reqHeal(caster):
	pPlot = caster.plot()
	iPoisoned = gc.getInfoTypeForString('PROMOTION_POISONED')
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if (pUnit.isAlive() and pUnit.getDamage() > 0):
			return True
		if pUnit.isHasPromotion(iPoisoned):
			return True
	return False

def spellHeal(caster,amount):
	pPlot = caster.plot()
	iPoisoned = gc.getInfoTypeForString('PROMOTION_POISONED')
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		pUnit.setHasPromotion(iPoisoned,False)
		if pUnit.isAlive():
			pUnit.changeDamage(-amount,0)

def reqSanctify(caster):
	pPlot = caster.plot()
	bValid = False
	if pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FALLOUT'):
		bValid = True
	if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_BARROW'):
		return True
	if bValid == False:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if (pPlayer.isHuman() == False and caster.getOwner() != pPlot.getOwner()):
		return False
	return True

def spellSanctify(caster):
	pPlot = caster.plot()
	if pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FALLOUT'):
		pPlot.setFeatureType(-1, -1)
	if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_BARROW'):
		pPlot.setImprovementType(-1)

		
		
#Nurgle
def reqcorruptionstream(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellcorruptionstream(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(40, 60, caster, gc.getInfoTypeForString('DAMAGE_POISON'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_CONTAGION'),pBestPlot.getPoint())
	
def reqDefile(caster):
	pPlot = caster.plot()
	if pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FALLOUT'):
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if (pPlayer.isHuman() and caster.getOwner() == pPlot.getOwner()):
		return True
	if pPlot.isOwned():
		iTeam = gc.getPlayer(caster.getOwner()).getTeam()
		i2Team = gc.getPlayer(pPlot.getOwner()).getTeam()
		eTeam = gc.getTeam(iTeam)
		if eTeam.isAtWar(i2Team) == False:
			return False
	return True

def reqPillarofCorruption(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellPillarofCorruption(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(50, 75, caster, gc.getInfoTypeForString('DAMAGE_POISON'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_CONTAGION'),pBestPlot.getPoint())	

#Tzeentch
def reqTzeentchsFirestorm(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellTzeentchsFirestorm(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(50, 60, caster, gc.getInfoTypeForString('DAMAGE_UNHOLY'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_METEOR_SWARM'),pBestPlot.getPoint())

#Skaven
def reqWarpBolt(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellWarpBolt(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(20, 35, caster, gc.getInfoTypeForString('DAMAGE_LIGHTNING'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SPIRITUAL_HAMMER'),pBestPlot.getPoint())

def reqWarpLightning(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellWarpLightning(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(30, 45, caster, gc.getInfoTypeForString('DAMAGE_LIGHTNING'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SPIRITUAL_HAMMER'),pBestPlot.getPoint())

def reqPestilentbreath(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellPestilentbreath(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(60, 80, caster, gc.getInfoTypeForString('DAMAGE_POISON'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_CONTAGION'),pBestPlot.getPoint())

def reqSkitterLeap(caster):
	if caster.getOwner() == gc.getBARBARIAN_PLAYER():
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if (pPlayer.isHuman() == False and caster.getDamage() >= 50):
		return False
	return True
		
def spellSkitterLeap(caster,loc):
	player = caster.getOwner()
	pPlayer = gc.getPlayer(player)
	pCity = pPlayer.getCapitalCity()
	caster.setXY(pCity.getX(), pCity.getY(), true, true, true)


#abilities		
def reqMarch(caster):
	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_FATIGUED')):
		return False
	return True

	
#def postCombatConsumePaladin(pCaster, pOpponent):
#	if (pOpponent.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_PALADIN')):
#		pCaster.setDamage(0, pCaster.getOwner())
#		CyInterface().addMessage(pCaster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_CONSUME_PALADIN", ()),'',1,'Art/Interface/Buttons/Units/Beast of Agares.dds',ColorTypes(8),pCaster.getX(),pCaster.getY(),True,True)

#def postCombatDonal(pCaster, pOpponent):
#	if (pOpponent.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON')) or pOpponent.isHasPromotion(gc.getInfoTypeForString('PROMOTION_UNDEAD'))):
#		pCaster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_RECRUITER'), True)
		
#def postCombatIra(pCaster, pOpponent):
#	if pOpponent.isAlive():
#		if pCaster.baseCombatStr() < 32:
#			pCaster.setBaseCombatStr(pCaster.baseCombatStr() - 3)
#			pCaster.setBaseCombatStrDefense(pCaster.baseCombatStrDefense() - 3)
#
#def postCombatMimic(pCaster, pOpponent):
#	iChanneling3 = gc.getInfoTypeForString('PROMOTION_CHANNELING3')
#	iDivine = gc.getInfoTypeForString('PROMOTION_DIVINE')
#	listProms = []
#	for iCount in range(gc.getNumPromotionInfos()):
#		if (pOpponent.isHasPromotion(iCount)):
#			if gc.getPromotionInfo(iCount).isEquipment() == False:
#				if (iCount != iChanneling3 and iCount != iDivine):
#					if gc.getPromotionInfo(iCount).isRace() == false:
#						listProms.append(iCount)
#	if len(listProms) > 0:
#		iRnd = CyGame().getSorenRandNum(len(listProms), "Mimic")
#		pCaster.setHasPromotion(listProms[iRnd], True)
#		CyInterface().addMessage(pCaster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_PROMOTION_STOLEN", ()),'',1,gc.getPromotionInfo(listProms[iRnd]).getButton(),ColorTypes(8),pCaster.getX(),pCaster.getY(),True,True)
#
#def postCombatReduceCombat1(pCaster, pOpponent):
#	if pOpponent.isAlive():
#		if pCaster.baseCombatStr() > 5:
#			pCaster.setBaseCombatStr(pCaster.baseCombatStr() - 5)
#			pCaster.setBaseCombatStrDefense(pCaster.baseCombatStrDefense() - 5)
#			CyInterface().addMessage(pCaster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_STRENGTH_REDUCED", ()),'',1,'Art/Interface/Buttons/Units/Repentant Angel.dds',ColorTypes(7),pCaster.getX(),pCaster.getY(),True,True)
			
#def postCombatWolfRider(pCaster, pOpponent):
#	if (pOpponent.getUnitType() == gc.getInfoTypeForString('UNIT_WOLF') or pOpponent.getUnitType() == gc.getInfoTypeForString('UNIT_WOLF_PACK')):
#		CyInterface().addMessage(pCaster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_WOLF_RIDER", ()),'',1,'Art/Interface/Buttons/Units/Wolf Rider.dds',ColorTypes(8),pCaster.getX(),pCaster.getY(),True,True)
#		pPlayer = gc.getPlayer(pCaster.getOwner())
#		newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_WOLF_RIDER'), pCaster.getX(), pCaster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#		newUnit.convert(pCaster)

#def reqAddToFleshGolem(caster):
#	if caster.isAlive() == False:
#		return False
#	if caster.getDuration() != 0:
#		return False
#	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL')):
#		return false
#	return True

#def spellAddToFleshGolem(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	pPlot = caster.plot()
#	iChanneling = gc.getInfoTypeForString('PROMOTION_CHANNELING')
#	iChanneling2 = gc.getInfoTypeForString('PROMOTION_CHANNELING2')
#	iChanneling3 = gc.getInfoTypeForString('PROMOTION_CHANNELING3')
#	iDivine = gc.getInfoTypeForString('PROMOTION_DIVINE')
#	iFleshGolem = gc.getInfoTypeForString('UNITCLASS_FLESH_GOLEM')
#	pFleshGolem = -1
#	for i in range(pPlot.getNumUnits()):
#		pUnit = pPlot.getUnit(i)
#		if (caster.getOwner() == pUnit.getOwner() and pUnit.getUnitClassType() == iFleshGolem):
#			pFleshGolem = pUnit
#	if pFleshGolem != -1:
#		if caster.baseCombatStr() > pFleshGolem.baseCombatStr():
#			pFleshGolem.setBaseCombatStr(pFleshGolem.baseCombatStr() + 1)
#		if caster.baseCombatStrDefense() > pFleshGolem.baseCombatStrDefense():
#			pFleshGolem.setBaseCombatStrDefense(pFleshGolem.baseCombatStrDefense() + 1)
#		for iCount in range(gc.getNumPromotionInfos()):
#			if (caster.isHasPromotion(iCount)):
#				if (iCount != iChanneling and iCount != iChanneling2 and iCount != iChanneling3 and iCount != iDivine):
#					if gc.getPromotionInfo(iCount).isRace() == false:
#						pFleshGolem.setHasPromotion(iCount, true)

#def reqAddToFreakShow(caster):
#	pCity = caster.plot().getPlotCity()
#	if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_FREAK_SHOW')) == 0:
#		return False
#	iCage = gc.getInfoTypeForString('BUILDING_HUMAN_CAGE')
#	if caster.getRace() == gc.getInfoTypeForString('PROMOTION_ORC'):
#		iCage = gc.getInfoTypeForString('BUILDING_ORC_CAGE')
#	if caster.getRace() == gc.getInfoTypeForString('PROMOTION_ELF'):
#		iCage = gc.getInfoTypeForString('BUILDING_ELF_CAGE')
#	if caster.getRace() == gc.getInfoTypeForString('PROMOTION_DWARF'):
#		iCage = gc.getInfoTypeForString('BUILDING_DWARF_CAGE')
#	if pCity.getNumRealBuilding(iCage) > 0:
#		return False
#	return True

#def spellAddToFreakShow(caster):
#	pCity = caster.plot().getPlotCity()
#	iCage = gc.getInfoTypeForString('BUILDING_HUMAN_CAGE')
#	if caster.getRace() == gc.getInfoTypeForString('PROMOTION_ORC'):
#		iCage = gc.getInfoTypeForString('BUILDING_ORC_CAGE')
#	if caster.getRace() == gc.getInfoTypeForString('PROMOTION_ELF'):
#		iCage = gc.getInfoTypeForString('BUILDING_ELF_CAGE')
#	if caster.getRace() == gc.getInfoTypeForString('PROMOTION_DWARF'):
#		iCage = gc.getInfoTypeForString('BUILDING_DWARF_CAGE')
#	pCity.setNumRealBuilding(iCage, 1)

#def reqAeronsBounty(caster):
#	iAeronsBounty = gc.getInfoTypeForString('CORPORATION_AERONS_BOUNTY')
#	pCity = caster.plot().getPlotCity()
#	if pCity.isHasCorporation(iAeronsBounty):
#		return False
#	return True

#def spellAeronsBounty(caster):
#	iAeronsBounty = gc.getInfoTypeForString('CORPORATION_AERONS_BOUNTY')
#	pCity = caster.plot().getPlotCity()
#	if CyGame().isCorporationFounded(iAeronsBounty) == False:
#		pCity.setHeadquarters(iAeronsBounty)
#	pCity.setHasCorporation(iAeronsBounty, True, False, False)

#def reqArcaneLacuna(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	manaTypes = [ 'BONUS_MANA_AIR','BONUS_MANA_BODY','BONUS_MANA_CHAOS','BONUS_MANA_DEATH','BONUS_MANA_EARTH','BONUS_MANA_ENCHANTMENT','BONUS_MANA_ENTROPY','BONUS_MANA_FIRE','BONUS_MANA_LAW','BONUS_MANA_LIFE','BONUS_MANA_METAMAGIC','BONUS_MANA_MIND','BONUS_MANA_NATURE','BONUS_MANA_SHADOW','BONUS_MANA_SPIRIT','BONUS_MANA_SUN','BONUS_MANA_WATER' ]
#	iCount = 0
#	for szBonus in manaTypes:
#		iBonus = gc.getInfoTypeForString(szBonus)
#		iCount += CyMap().getNumBonuses(iBonus)
#	if iCount == 0:
#		return False
#	if pPlayer.isHuman() == False:
#		if iCount < 7:
#			return False
#	return True

#def spellArcaneLacuna(caster):
#	manaTypes = [ 'BONUS_MANA_AIR','BONUS_MANA_BODY','BONUS_MANA_CHAOS','BONUS_MANA_DEATH','BONUS_MANA_EARTH','BONUS_MANA_ENCHANTMENT','BONUS_MANA_ENTROPY','BONUS_MANA_FIRE','BONUS_MANA_LAW','BONUS_MANA_LIFE','BONUS_MANA_METAMAGIC','BONUS_MANA_MIND','BONUS_MANA_NATURE','BONUS_MANA_SHADOW','BONUS_MANA_SPIRIT','BONUS_MANA_SUN','BONUS_MANA_WATER' ]
#	iAdept = gc.getInfoTypeForString('UNITCOMBAT_ADEPT')
#	iBCMana = gc.getInfoTypeForString('BONUSCLASS_MANA')
#	iMana = gc.getInfoTypeForString('BONUS_MANA')
#	iSepulcher = gc.getInfoTypeForString('IMPROVEMENT_BROKEN_SEPULCHER')
#	iPyre = gc.getInfoTypeForString('IMPROVEMENT_PYRE_OF_THE_SERAPHIC')
#	iCount = 0
#	for szBonus in manaTypes:
#		iBonus = gc.getInfoTypeForString(szBonus)
#		iCount += CyMap().getNumBonuses(iBonus)
#	py = PyPlayer(caster.getOwner())
#	for pUnit in py.getUnitList():
#		if pUnit.getUnitCombatType() == iAdept:
#			pUnit.changeExperience(iCount, -1, False, False, False)
#	for i in range (CyMap().numPlots()):
#		pPlot = CyMap().plotByIndex(i)
#		if pPlot.getBonusType(-1) != -1:
#			if gc.getBonusInfo(pPlot.getBonusType(-1)).getBonusClassType() == iBCMana:
#				iImprovement = pPlot.getImprovementType()
#				if iImprovement != -1:
#					if gc.getImprovementInfo(iImprovement).isPermanent() == False:
#						if iImprovement != iSepulcher and iImprovement != iPyre:
#							pPlot.setImprovementType(-1)
#							pPlot.setBonusType(iMana)

#def reqArdor(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.getGreatPeopleCreated() == 0:
#		return False
#	if pPlayer.isHuman() == False:
#		if pPlayer.getGreatPeopleCreated() < 5:
#			return False
#	return True

#def spellArdor(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	pPlayer.setGreatPeopleCreated(0)
#	pPlayer.setGreatPeopleThresholdModifier(0)

def reqArenaBattle(caster):
	pCity = caster.plot().getPlotCity()
	if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_BLOODBOWL')) == 0:
		return false
	if (caster.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_MELEE') and caster.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_RECON') and caster.getUnitClassType() != gc.getInfoTypeForString('UNITCLASS_SLAVE')):
		return false
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == false:
		if caster.getExperience() != 0:
			return false
	return True

def spellArenaBattle(caster):
	pCity = caster.plot().getPlotCity()
	pCity.changeHappinessTimer(3)
	if CyGame().getSorenRandNum(100, "Arena Battle") < 50:
		caster.changeExperience(CyGame().getSorenRandNum(6, "Arena Battle") + 1, -1, False, False, False)
		caster.setDamage(25, caster.getOwner())
		CyInterface().addMessage(caster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_BLOODBOWL_WIN", ()),'',1,'Art/Interface/Buttons/Buildings/Bloodbowl.dds',ColorTypes(8),caster.getX(),caster.getY(),True,True)
		if caster.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_SLAVE'):
			pPlayer = gc.getPlayer(caster.getOwner())
			newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_WARRIOR'), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
			newUnit.convert(caster)
	else:
		CyInterface().addMessage(caster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_BLOODBOWL_LOSE", ()),'',1,'Art/Interface/Buttons/Buildings/Bloodbowl.dds',ColorTypes(7),caster.getX(),caster.getY(),True,True)
		caster.kill(True, 0)

#def reqCommanderJoin(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_GREAT_COMMANDER')):
#		return False
#	if caster.getDuration() != 0:
#		return False
#	if pPlayer.isHuman() == False:
#		if caster.baseCombatStr() <= 5:
#			return False
#	return True

#def spellCommanderJoin(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	pPlot = caster.plot()
#	iCommander = gc.getInfoTypeForString('UNITCLASS_COMMANDER')
#	pCommander = -1
#	for i in range(pPlot.getNumUnits()):
#		pUnit = pPlot.getUnit(i)
#		if (caster.getOwner() == pUnit.getOwner() and pUnit.getUnitClassType() == iCommander):
#			pCommander = pUnit
#	if pCommander != -1:
#		pCommander.setHasPromotion(gc.getInfoTypeForString('PROMOTION_GOLEM'), True)
#		pCommander.kill(False,0)

#def reqCommanderSplit(caster):
#	if caster.getDuration() != 0:
#		return False
#	return True

#def spellCommanderSplit(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_COMMANDER'), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)

#def reqConvertCity(caster):
#	pPlot = caster.plot()
#	pCity = pPlot.getPlotCity()
#	if pCity.getOwner() == caster.getOwner():
#		return False
#	if (pCity.getOwner() == gc.getBARBARIAN_PLAYER() and caster.getUnitType() == gc.getInfoTypeForString('UNIT_RANTINE')):
#		for i in range(pPlot.getNumUnits()):
#			pUnit = pPlot.getUnit(i)
#			if pUnit.baseCombatStr() > caster.baseCombatStr():
#				return False
#		return True
#	if caster.getUnitType() == gc.getInfoTypeForString('UNIT_BASIUM'):
#		if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_MERCURIAN_GATE')) == 1:
#			return True
#	return False

#def spellConvertCity(caster):
#	pCity = caster.plot().getPlotCity()
#	pPlayer = gc.getPlayer(caster.getOwner())
#	pPlayer.acquireCity(pCity,false,false)

def reqCreateDen(caster):
	iImprovement = -1
	if caster.getUnitType() == gc.getInfoTypeForString('UNIT_RIVERTROLL'):
		iImprovement = gc.getInfoTypeForString('IMPROVEMENT_TROLLCAVE')
	if caster.getUnitType() == gc.getInfoTypeForString('UNIT_BEAR'):
		iImprovement = gc.getInfoTypeForString('IMPROVEMENT_BEAR_DEN')
	if iImprovement == -1:
		return False
	if caster.getDamage() > 0:
		return False
	pPlot = caster.plot()
	if pPlot.isOwned():
		return False
	if pPlot.getNumUnits() != 1:
		return False
	if pPlot.getImprovementType() != -1:
		return False
	if pPlot.canHaveImprovement(iImprovement, caster.getOwner(), true) == False:
		return False
	iX = pPlot.getX()
	iY = pPlot.getY()
	for iiX in range(iX-4, iX+5, 1):
		for iiY in range(iY-4, iY+5, 1):
			pPlot2 = CyMap().plot(iiX,iiY)
			if pPlot2.getImprovementType() == iImprovement:
				return False
	return True

def spellCreateDen(caster):
	pPlot = caster.plot()
	iImprovement = -1
	if caster.getUnitType() == gc.getInfoTypeForString('UNIT_RIVERTROLL'):
		iImprovement = gc.getInfoTypeForString('IMPROVEMENT_TROLLCAVE')
		iUnit = gc.getInfoTypeForString('UNIT_RIVERTROLL')
	if caster.getUnitType() == gc.getInfoTypeForString('UNIT_BEAR'):
		iImprovement = gc.getInfoTypeForString('IMPROVEMENT_BEAR_DEN')
		iUnit = gc.getInfoTypeForString('UNIT_BEAR')
	pPlot.setImprovementType(iImprovement)
	pPlot2 = findClearPlot(-1, caster.plot())
	if pPlot2 != -1:
		caster.setXY(pPlot2.getX(), pPlot2.getY(), false, true, true)
		pPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
		newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
		newUnit.convert(caster)

def reqCrewBuccaneers(caster):
	if caster.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_NAVAL'):
		return False
	pPlot = caster.plot()
	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_BUCCANEERS')):
		return False
	if caster.maxMoves() <= 1:
		return False
	if caster.baseCombatStr() < 1:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	return true

def reqCrewLongshoremen(caster):
	if caster.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_NAVAL'):
		return False
	pPlot = caster.plot()
	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_LONGSHOREMEN')):
		return False
#	if (PyInfo.UnitInfo(caster.getUnitType()).getCargoSpace() == 0 and caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_EXPANDED_HULL')) == False):
#		return False
	if caster.cargoSpaceAvailable(-1, gc.getInfoTypeForString('DOMAIN_LAND')) == 0:
		return False
	if caster.baseCombatStr() < 1:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	return True

def reqCrewNormalCrew(caster):
	pPlot = caster.plot()
	if (caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_BUCCANEERS')) == False and caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SKELETON_CREW')) == False and caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_LONGSHOREMEN')) == False):
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		return False
	return True

def reqCrewSkeletonCrew(caster):
	if caster.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_NAVAL'):
		return False
	pPlot = caster.plot()
	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_SKELETON_CREW')):
		return False
	if caster.baseCombatStr() < 1:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	return True

#def effectCrownOfBrillance(caster):
#	caster.cast(gc.getInfoTypeForString('SPELL_CROWN_OF_BRILLANCE'))

#def reqCrownOfBrillance(caster):
#	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CROWN_OF_BRILLANCE')):
#		return False
#	return True

def reqCrush(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellCrush(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(50, 75, caster, gc.getInfoTypeForString('DAMAGE_PHYSICAL'), true)
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_CRUSH'),pBestPlot.getPoint())

def reqDestroyUndead(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	eTeam = pPlayer.getTeam()
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if pUnit.getRace() == gc.getInfoTypeForString('PROMOTION_UNDEAD'):
					if pPlayer.isHuman():
						return True
					p2Player = gc.getPlayer(pUnit.getOwner())
					e2Team = gc.getTeam(p2Player.getTeam())
					if e2Team.isAtWar(eTeam):
						return True
	return False

def spellDestroyUndead(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if pUnit.getRace() == gc.getInfoTypeForString('PROMOTION_UNDEAD'):
					pUnit.doDamage(20, 50, caster, gc.getInfoTypeForString('DAMAGE_HOLY'), true)

def reqDispelMagic(caster):
	if caster.canDispel(gc.getInfoTypeForString('SPELL_DISPEL_MAGIC')):
		return True
	return False

def reqDivineRetribution(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		iTeam = gc.getPlayer(caster.getOwner()).getTeam()
		eTeam = gc.getTeam(iTeam)
		if eTeam.getAtWarCount(True) < 2:
			return False
	return True

def spellDivineRetribution(caster):
	iDemon = gc.getInfoTypeForString('PROMOTION_DEMON')
	iUndead = gc.getInfoTypeForString('PROMOTION_UNDEAD')
	for iPlayer in range(gc.getMAX_PLAYERS()):
		player = gc.getPlayer(iPlayer)
		if player.isAlive():
			py = PyPlayer(iPlayer)
			for pUnit in py.getUnitList():
				if (pUnit.getRace() == iDemon or pUnit.getRace() == iUndead):
					pUnit.doDamage(50, 100, caster, gc.getInfoTypeForString('DAMAGE_HOLY'), false)



def reqEarthquake(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		eTeam = pPlayer.getTeam()
		for iiX in range(iX-1, iX+2, 1):
			for iiY in range(iY-1, iY+2, 1):
				pPlot = CyMap().plot(iiX,iiY)
				p2Player = gc.getPlayer(pPlot.getOwner())
				if pPlot.isOwned():
					e2Team = gc.getTeam(p2Player.getTeam())
					if e2Team.isAtWar(eTeam) == False:
						return False
	return True

def spellEarthquake(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	eTeam = pPlayer.getTeam()
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			if (pPlot.isCity() or pPlot.getImprovementType() != -1):
				if pPlot.isOwned():
					startWar(caster.getOwner(), pPlot.getOwner())
			if pPlot.isCity():
				pCity = pPlot.getPlotCity()
				for i in range(gc.getNumBuildingInfos()):
					iRnd = CyGame().getSorenRandNum(100, "Bob")
					if (gc.getBuildingInfo(i).getConquestProbability() != 100 and iRnd <= 25):
							pCity.setNumRealBuilding(i, 0)
			for iUnit in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(iUnit)
				if pUnit.isFlying() == False:
					pUnit.setFortifyTurns(0)
			iRnd = CyGame().getSorenRandNum(100, "Bob")
			if iRnd <= 25:
				pPlot.setImprovementType(-1)

def reqFeast(caster):
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	if pCity.getPopulation() < 3:
		return False
	return True

def spellFeast(caster):
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	caster.changeExperience(pCity.getPopulation()-2, -1, false, false, false)
	pCity.changeHurryAngerTimer(3)

def reqFeed(caster):
	if caster.getDamage() == 0:
		return false
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == false:
		if caster.getDamage() < 20:
			return false
	return true

def spellFeed(caster):
	caster.setDamage(caster.getDamage() - 20, caster.getOwner())
	pVictim = -1
	pPlot = caster.plot()
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if pUnit.getOwner() == caster.getOwner():
			if pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_MERCENARY'):
				if (pVictim == -1 or pVictim.getLevel() > pUnit.getLevel()):
					pVictim = pUnit
	if pVictim != -1:
		pVictim.kill(True, 0)

#def reqForTheHorde(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
#	if bPlayer.getNumUnits() == 0:
#		return False
#	if pPlayer.isHuman() == False:
#		if bPlayer.getNumUnits() < 60:
#			return False
#	return True

#def spellForTheHorde(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	iHero = gc.getInfoTypeForString('PROMOTION_HERO')
#	iOrc = gc.getInfoTypeForString('PROMOTION_ORC')
#	py = PyPlayer(gc.getBARBARIAN_PLAYER())
#	for pUnit in py.getUnitList():
#		if (pUnit.getRace() == iOrc and pUnit.isHasPromotion(iHero) == False):
#			if CyGame().getSorenRandNum(100, "Bob") < 50:
#				newUnit = pPlayer.initUnit(pUnit.getUnitType(), pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#				newUnit.convert(pUnit)

#def reqGiftsOfNantosuelta(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.getNumCities() == 0:
#		return False
#	if pPlayer.isHuman() == False:
#		if pPlayer.getNumCities() < 5:
#			return False
#	return True

#def spellGiftsOfNantosuelta(caster):
#	iGoldenHammer = gc.getInfoTypeForString('EQUIPMENT_GOLDEN_HAMMER')
#	pPlayer = gc.getPlayer(caster.getOwner())
#	for iCity in range(pPlayer.getNumCities()):
#		pCity = pPlayer.getCity(iCity)
#		newUnit = pPlayer.initUnit(iGoldenHammer, pCity.getX(), pCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)

#def reqGiftVampirism(caster):
#	pPlot = caster.plot()
#	for i in range(pPlot.getNumUnits()):
#		pUnit = pPlot.getUnit(i)
#		if (pUnit.isAlive() and pUnit.getOwner() == caster.getOwner()):
#			if not pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_VAMPIRE')):
#				if pUnit.getLevel() >= 6:
#					return True
#				if (pUnit.getLevel() >= 4 and pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_MOROI')):
#					return True
#	return False

#def spellGiftVampirism(caster):
#	pPlot = caster.plot()
#	for i in range(pPlot.getNumUnits()):
#		pUnit = pPlot.getUnit(i)
#		if (pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON')) == False and pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_UNDEAD')) == False):
#			if not pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_VAMPIRE')):
#				if pUnit.getLevel() >= 6:
#					pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_VAMPIRE'),True)
#				if (pUnit.getLevel() >= 4 and pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_MOROI')):
#					pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_VAMPIRE'),True)

#def spellGiveHammerToCraftsman(caster):
#	pCity = caster.plot().getPlotCity()
#	pCity.changeFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_ENGINEER'), 1)

#def reqHastursRazor(caster):
#	iX = caster.getX()
#	iY = caster.getY()
#	pPlayer = gc.getPlayer(caster.getOwner())
#	eTeam = pPlayer.getTeam()
#	for iiX in range(iX-1, iX+2, 1):
#		for iiY in range(iY-1, iY+2, 1):
#			pPlot = CyMap().plot(iiX,iiY)
#			for i in range(pPlot.getNumUnits()):
#				pUnit = pPlot.getUnit(i)
#				if pUnit.getDamage() > 0:
#					if pPlayer.isHuman():
#						return True
#					if pUnit.getOwner() == caster.getOwner():
#						return True
#	return False

#def spellHastursRazor(caster):
#	iX = caster.getX()
#	iY = caster.getY()
#	pPlayer = gc.getPlayer(caster.getOwner())
#	listDamage = []
#	for iiX in range(iX-1, iX+2, 1):
#		for iiY in range(iY-1, iY+2, 1):
#			pPlot = CyMap().plot(iiX,iiY)
#			for i in range(pPlot.getNumUnits()):
#				pUnit = pPlot.getUnit(i)
#				listDamage.append(pUnit.getDamage())
#	for iiX in range(iX-1, iX+2, 1):
#		for iiY in range(iY-1, iY+2, 1):
#			pPlot = CyMap().plot(iiX,iiY)
#			for i in range(pPlot.getNumUnits()):
#				pUnit = pPlot.getUnit(i)
#				iRnd = listDamage[CyGame().getSorenRandNum(len(listDamage), "Hasturs Razor")]
#				if iRnd != pUnit.getDamage():
#					CyInterface().addMessage(pUnit.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_HASTURS_RAZOR",()),'AS2D_CHARM_PERSON',1,'Art/Interface/Buttons/Spells/Hasturs Razor.dds',ColorTypes(7),pUnit.getX(),pUnit.getY(),True,True)
#					if pUnit.getOwner() != caster.getOwner():
#						CyInterface().addMessage(caster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_HASTURS_RAZOR",()),'AS2D_CHARM_PERSON',1,'Art/Interface/Buttons/Spells/Hasturs Razor.dds',ColorTypes(8),pUnit.getX(),pUnit.getY(),True,True)
#					pUnit.setDamage(iRnd, caster.getOwner())

def reqHealingSalve(caster):
	if caster.getDamage() == 0:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		if caster.getDamage() < 25:
			return False
	return True

def spellHealingSalve(caster):
	caster.setDamage(0, caster.getOwner())

#def reqHellfire(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
#		return False
#	pPlot = caster.plot()
#	if pPlot.isCity():
#		return False
#	if pPlot.isWater():
#		return False
#	iHellFire = gc.getInfoTypeForString('IMPROVEMENT_HELLFIRE')
#	iX = pPlot.getX()
#	iY = pPlot.getY()
#	for iiX in range(iX-2, iX+3, 1):
#		for iiY in range(iY-2, iY+3, 1):
#			pPlot2 = CyMap().plot(iiX,iiY)
#			if pPlot2.getImprovementType() == iHellFire:
#				return False
#	if pPlayer.isHuman() == False:
#		if pPlot.isOwned():
#			if pPlot.getOwner() == caster.getOwner():
#				return False
#	return True

#def reqHeraldsCall(caster):
#	pPlot = caster.plot()
#	for i in range(pPlot.getNumUnits()):
#		pUnit = pPlot.getUnit(i)
#		if (pUnit.isAlive() and pUnit.getOwner() == caster.getOwner()):
#			return true
#	return False

#def spellHeraldsCall(caster):
#	iValor = gc.getInfoTypeForString('PROMOTION_VALOR')
#	iBurningBlood = gc.getInfoTypeForString('PROMOTION_BURNING_BLOOD')
#	iCourage = gc.getInfoTypeForString('PROMOTION_COURAGE')
#	iLoyalty = gc.getInfoTypeForString('PROMOTION_LOYALTY')
#	pPlot = caster.plot()
#	for i in range(pPlot.getNumUnits()):
#		pUnit = pPlot.getUnit(i)
#		if (pUnit.isAlive() and pUnit.getOwner() == caster.getOwner()):
#			pUnit.setHasPromotion(iValor,True)
#			pUnit.setHasPromotion(iBurningBlood, True)
#			pUnit.setHasPromotion(iCourage, True)
#			pUnit.setHasPromotion(iLoyalty, True)
#			pUnit.setDuration(1)

def reqHide(caster):
	if caster.isMadeAttack():
		return False
	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN')):
		return False
	return True

#def reqHyboremsWhisper(caster):
#	if gc.getGame().isNetworkMultiPlayer():
#		return False
#	pCity = cf.getAshenVeilCity(3)
#	if pCity == -1:
#		return False
#	return True

#def spellHyboremsWhisper(caster):
#	iPlayer = caster.getOwner()
#	pPlayer = gc.getPlayer(iPlayer)
#	iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_HYBOREMS_WHISPER')
#	triggerData = pPlayer.initTriggeredData(iEvent, true, -1, caster.getX(), caster.getY(), iPlayer, -1, -1, -1, -1, -1)

def reqImpersonateLeader(caster):
	pCity = caster.plot().getPlotCity()
	if pCity.getOwner() == caster.getOwner():
		return False
	if gc.getPlayer(pCity.getOwner()).isHuman():
		return False
	return True

def spellImpersonateLeader(caster):
	pCity = caster.plot().getPlotCity()
	iNewPlayer = pCity.getOwner()
	iOldPlayer = caster.getOwner()
	iTimer = 5 + CyGame().getSorenRandNum(10, "Impersonate Leader")
	CyGame().reassignPlayerAdvanced(iOldPlayer, iNewPlayer, iTimer)

def reqInquisition(caster):
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	pPlayer = gc.getPlayer(caster.getOwner())
	StateBelief = pPlayer.getStateReligion()
	if (StateBelief != gc.getPlayer(pCity.getOwner()).getStateReligion()):
		return False
	for iTarget in range(gc.getNumReligionInfos()):
		if (StateBelief != iTarget and pCity.isHasReligion(iTarget) and pCity.isHolyCityByType(iTarget) == False):
			return True
	return False

def spellInquisition(caster):
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	pPlayer = gc.getPlayer(caster.getOwner())
	StateBelief = gc.getPlayer(pCity.getOwner()).getStateReligion()
	iRnd = CyGame().getSorenRandNum(4, "Bob")
	if StateBelief == gc.getInfoTypeForString('RELIGION_SALVATION'):
		iRnd = iRnd - 1
	for iTarget in range(gc.getNumReligionInfos()):
		if (not StateBelief == iTarget and pCity.isHasReligion(iTarget) and not pCity.isHolyCityByType(iTarget)):
			pCity.setHasReligion(iTarget, False, True, True)
			iRnd = iRnd + 1
			for i in range(gc.getNumBuildingInfos()):
				if gc.getBuildingInfo(i).getPrereqReligion() == iTarget:
					pCity.setNumRealBuilding(i, 0)
	if iRnd >= 1:
		pCity.changeHurryAngerTimer(iRnd)

def reqIntoTheMist(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		if pPlayer.getNumUnits() < 40:
			return False
	return True

def spellIntoTheMist(caster):
	iInvisible = gc.getInfoTypeForString('PROMOTION_HIDDEN')
	py = PyPlayer(caster.getOwner())
	for pUnit in py.getUnitList():
		pUnit.setHasPromotion(iInvisible, True)

#def reqIraUnleashed(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_IRA')) >= 4:
#		return False
#	return True

#def spellIraUnleashed(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	iCount = 4 - pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_IRA'))
#	for i in range(iCount):
#		pPlayer.initUnit(gc.getInfoTypeForString('UNIT_IRA'), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)

def reqKidnap(caster):
	pCity = caster.plot().getPlotCity()
	if pCity.getTeam() == caster.getTeam():
		return False
	i = 0
	i = i + pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_PRIEST'))
	i = i + pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_ARTIST'))
	i = i + pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_MERCHANT'))
	i = i + pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_ENGINEER'))
	i = i + pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_SCIENTIST'))
	if i == 0:
		return False
	return True

def spellKidnap(caster):
	pCity = caster.plot().getPlotCity()
	if pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_PRIEST')) > 0:
		iUnit = gc.getInfoTypeForString('UNIT_PROPHET')
		iSpec = gc.getInfoTypeForString('SPECIALIST_GREAT_PRIEST')
	if pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_ARTIST')) > 0:
		iUnit = gc.getInfoTypeForString('UNIT_ARTIST')
		iSpec = gc.getInfoTypeForString('SPECIALIST_GREAT_ARTIST')
	if pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_MERCHANT')) > 0:
		iUnit = gc.getInfoTypeForString('UNIT_MERCHANT')
		iSpec = gc.getInfoTypeForString('SPECIALIST_GREAT_MERCHANT')
	if pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_ENGINEER')) > 0:
		iUnit = gc.getInfoTypeForString('UNIT_ENGINEER')
		iSpec = gc.getInfoTypeForString('SPECIALIST_GREAT_ENGINEER')
	if pCity.getFreeSpecialistCount(gc.getInfoTypeForString('SPECIALIST_GREAT_SCIENTIST')) > 0:
		iUnit = gc.getInfoTypeForString('UNIT_SCIENTIST')
		iSpec = gc.getInfoTypeForString('SPECIALIST_GREAT_SCIENTIST')
	iChance = caster.baseCombatStr() * 8
	if iChance > 95:
		iChance = 95
	pPlayer = gc.getPlayer(caster.getOwner())
	if CyGame().getSorenRandNum(100, "Kidnap") <= iChance:
		newUnit = pPlayer.initUnit(iUnit, caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
		pCity.changeFreeSpecialistCount(iSpec, -1)
	else:
		if CyGame().getSorenRandNum(100, "Kidnap") <= 50:
			caster.setXY(pPlayer.getCapitalCity().getX(), pPlayer.getCapitalCity().getY(), false, true, true)
		else:
			caster.kill(True, 0)
		startWar(caster.getOwner(), pCity.getOwner())

#def reqLegends(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.getNumCities() == 0:
#		return False
#	if pPlayer.isHuman() == False:
#		if pPlayer.getNumCities() < 5:
#			return False
#	return True

#def spellLegends(caster):
#	iPlayer = caster.getOwner()
#	pPlayer = gc.getPlayer(iPlayer)
#	for iCity in range(pPlayer.getNumCities()):
#		pCity = pPlayer.getCity(iCity)
#		pCity.changeCulture(iPlayer, 300, True)

def reqLichdom(caster):
	if caster.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_NAGASH'):
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_LICH')) >= 4:
		return False
	return True

def reqMask(caster):
	if caster.isHiddenNationality():
		return False
	if caster.hasCargo():
		return False
	if caster.isCargo():
		return False
	pGroup = caster.getGroup()
	if pGroup.isNone() == False:
		if pGroup.getNumUnits() > 1:
			return False
	return True

def reqMezmerizeAnimal(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ANIMAL'):
					if eTeam.isAtWar(pUnit.getTeam()):
						return True
	return False

def spellMezmerizeAnimal(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ANIMAL'):
					if eTeam.isAtWar(pUnit.getTeam()):
						if pUnit.isResisted(caster, gc.getInfoTypeForString('SPELL_MEZMERIZE_ANIMAL')) == False:
							newUnit = pPlayer.initUnit(pUnit.getUnitType(), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
							newUnit.convert(pUnit)

def spellPeace(caster):
	eTeam = gc.getTeam(gc.getPlayer(caster.getOwner()).getTeam())
	for iPlayer in range(gc.getMAX_PLAYERS()):
		pPlayer = gc.getPlayer(iPlayer)
		if (pPlayer.isAlive() and iPlayer != caster.getOwner() and iPlayer != gc.getBARBARIAN_PLAYER()):
			i2Team = gc.getPlayer(iPlayer).getTeam()
			if eTeam.isAtWar(i2Team):
				eTeam.makePeace(i2Team)
	CyGame().changeGlobalCounter(-1 * (CyGame().getGlobalCounter() / 2))

def reqPillarofFire(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			bEnemy = false
			bNeutral = false
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					bEnemy = true
				else:
					bNeutral = true
			if (bEnemy and bNeutral == false):
				return true
	return false

def spellPillarofFire(caster):
	iX = caster.getX()
	iY = caster.getY()
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	eTeam = gc.getTeam(iTeam)
	iBestValue = 0
	pBestPlot = -1
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			bNeutral = false
			iValue = 0
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if eTeam.isAtWar(pUnit.getTeam()):
					iValue = iValue + 10
				else:
					bNeutral = true
			if (iValue > iBestValue and bNeutral == false):
				iBestValue = iValue
				pBestPlot = pPlot
	if pBestPlot != -1:
		for i in range(pBestPlot.getNumUnits()):
			pUnit = pBestPlot.getUnit(i)
			pUnit.doDamage(50, 75, caster, gc.getInfoTypeForString('DAMAGE_FIRE'), true)
		if (pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE')):
			if CyGame().getSorenRandNum(100, "Flames Spread") <= gc.getDefineINT('FLAMES_SPREAD_CHANCE'):
				pPlot.setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_SMOKE'))
		CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_PILLAR_OF_FIRE'),pBestPlot.getPoint())

def reqMarchOfTheTrees(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		iTeam = gc.getPlayer(caster.getOwner()).getTeam()
		eTeam = gc.getTeam(iTeam)
		if eTeam.getAtWarCount(True) < 2:
			return False
	return True

def spellMarchOfTheTrees(caster):
	iAncientForest = gc.getInfoTypeForString('FEATURE_FOREST_ANCIENT')
	iForest = gc.getInfoTypeForString('FEATURE_FOREST')
	iNewForest = gc.getInfoTypeForString('FEATURE_FOREST_NEW')
	iTreant = gc.getInfoTypeForString('UNIT_TREEKIN')
	iPlayer = caster.getOwner()
	pPlayer = gc.getPlayer(iPlayer)
	for i in range (CyMap().numPlots()):
		pPlot = CyMap().plotByIndex(i)
		if pPlot.isOwned():
			if pPlot.getOwner() == iPlayer:
				if (pPlot.getFeatureType() == iForest or pPlot.getFeatureType() == iAncientForest):
					newUnit = pPlayer.initUnit(iTreant, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
					newUnit.setDuration(5)
					pPlot.setFeatureType(iNewForest,0)

#def reqMotherLode(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.isHuman() == False:
#		if pPlayer.getImprovementCount(gc.getInfoTypeForString('IMPROVEMENT_MINE')) < 10:
#			return False
#	return True

#def spellMotherLode(caster):
#	iPlayer = caster.getOwner()
#	pPlayer = gc.getPlayer(iPlayer)
#	pPlayer.changeGold(pPlayer.getImprovementCount(gc.getInfoTypeForString('IMPROVEMENT_MINE')) * 25)
#	for i in range (CyMap().numPlots()):
#		pPlot = CyMap().plotByIndex(i)
#		if pPlot.isOwned():
#			if pPlot.getOwner() == iPlayer:
#				if pPlot.isWater() == False:
#					if pPlot.isPeak() == False:
#						if pPlot.isHills() == False:
#							if CyGame().getSorenRandNum(100, "Mother Lode") < 10:
#								pPlot.setPlotType(PlotTypes.PLOT_HILLS, True, True)

def reqPromoteSettlement(caster):
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	if pCity.isSettlement() == False:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.getNumCities() - pPlayer.getNumSettlements() >= pPlayer.getMaxCities():
		return False
	return True

def spellPromoteSettlement(caster):
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	pCity.setSettlement(False)
	pCity.setPlotRadius(3)

#def reqRagingSeas(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.isHuman() == False:
#		eTeam = gc.getTeam(pPlayer.getTeam())
#		iArcane = gc.getInfoTypeForString('UNITCLASS_ARCANE_BARGE')
#		iCaravel = gc.getInfoTypeForString('UNITCLASS_CARAVEL')
#		iDragonship = gc.getInfoTypeForString('UNITCLASS_DRAGONSHIP')
#		iFrigate = gc.getInfoTypeForString('UNITCLASS_FRIGATE')
#		iGalleon = gc.getInfoTypeForString('UNITCLASS_GALLEON')
#		iManOWar = gc.getInfoTypeForString('UNITCLASS_MAN_O_WAR')
#		iPrivateer = gc.getInfoTypeForString('UNITCLASS_PRIVATEER')
#		iQueenOfTheLine = gc.getInfoTypeForString('UNITCLASS_QUEEN_OF_THE_LINE')
#		iTrireme = gc.getInfoTypeForString('UNITCLASS_TRIREME')
#		for iPlayer2 in range(gc.getMAX_PLAYERS()):
#			pPlayer2 = gc.getPlayer(iPlayer2)
#			if pPlayer2.isAlive():
#				iTeam2 = gc.getPlayer(iPlayer2).getTeam()
#				if eTeam.isAtWar(iTeam2):
#					iCount = pPlayer2.getUnitClassCount(iArcane)
#					iCount += pPlayer2.getUnitClassCount(iCaravel)
#					iCount += pPlayer2.getUnitClassCount(iDragonship)
#					iCount += pPlayer2.getUnitClassCount(iFrigate) * 2
#					iCount += pPlayer2.getUnitClassCount(iGalleon) * 2
#					iCount += pPlayer2.getUnitClassCount(iManOWar) * 3
#					iCount += pPlayer2.getUnitClassCount(iPrivateer)
#					iCount += pPlayer2.getUnitClassCount(iQueenOfTheLine) * 3
#					iCount += pPlayer2.getUnitClassCount(iTrireme)
#					if iCount > 10:
#						return True
#		return False
#	return True

#def spellRagingSeas(caster):
#	iCold = gc.getInfoTypeForString('DAMAGE_COLD')
#	iFlames = gc.getInfoTypeForString('FEATURE_FLAMES')
#	iLanun = gc.getInfoTypeForString('CIVILIZATION_LANUN')
#	iSmoke = gc.getInfoTypeForString('IMPROVEMENT_SMOKE')
#	iSpring = gc.getInfoTypeForString('EFFECT_SPRING')
#	for i in range (CyMap().numPlots()):
#		pPlot = CyMap().plotByIndex(i)
#		if pPlot.isAdjacentToWater():
#			for i in range(pPlot.getNumUnits()):
#				pUnit = pPlot.getUnit(i)
#				if pUnit.getCivilizationType() != iLanun:
#					pUnit.doDamageNoCaster(75, 100, iCold, false)
#			if pPlot.getImprovementType() != -1:
#				if pPlot.getFeatureType() == iFlames:
#					pPlot.setFeatureType(-1, 0)
#				if pPlot.getImprovementType() == iSmoke:
#					pPlot.setImprovementType(-1)
#				else:
#					if pPlot.isOwned():
#						if gc.getImprovementInfo(pPlot.getImprovementType()).isPermanent() == False:
#							if gc.getPlayer(pPlot.getOwner()).getCivilizationType() != iLanun:
#								if CyGame().getSorenRandNum(100, "Raging Seas") <= 25:
#									pPlot.setImprovementType(-1)
#			if pPlot.isVisibleToWatchingHuman():
#				CyEngine().triggerEffect(iSpring,pPlot.getPoint())

def spellRaiseSkeleton(caster):
	pPlot = caster.plot()
	if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_GRAVEYARD'):
		pPlot.setImprovementType(-1)
		caster.cast(gc.getInfoTypeForString('SPELL_RAISE_SKELETON'))
		caster.cast(gc.getInfoTypeForString('SPELL_RAISE_SKELETON'))

#def reqRally(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_CULTURAL_VALUES')) != gc.getInfoTypeForString('CIVIC_CRUSADE'):
#		return False
#	if pPlayer.isHuman() == False:
#		if pPlayer.getNumCities() < 5:
#			return False
#	return True

#def spellRally(caster):
#	iOwner = caster.getOwner()
#	pPlayer = gc.getPlayer(iOwner)
#	iDemagog = gc.getInfoTypeForString('UNIT_DEMAGOG')
#	iTown = gc.getInfoTypeForString('IMPROVEMENT_TOWN')
#	iVillage = gc.getInfoTypeForString('IMPROVEMENT_VILLAGE')
#	iCount = 0
#	for i in range (CyMap().numPlots()):
#		pPlot = CyMap().plotByIndex(i)
#		if pPlot.getOwner() == iOwner:
#			if pPlot.isCity():
#				newUnit = pPlayer.initUnit(iDemagog, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#			if pPlot.getImprovementType() == iTown:
#				pPlot.setImprovementType(iVillage)
#				newUnit = pPlayer.initUnit(iDemagog, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)

#def spellReadTheGrimoire(caster):
#	iRnd = CyGame().getSorenRandNum(100, "Read the Grimoire")
#	if iRnd < 20:
#		caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_SPECTRE'))
#	if iRnd >= 20 and iRnd < 40:
#		caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_UNHOLY_TAINT'), True)
#	if iRnd >= 40 and iRnd < 60:
#		caster.cast(gc.getInfoTypeForString('SPELL_WITHER'))
#	if iRnd >= 60 and iRnd < 70:
#		caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_PIT_BEAST'))
#	if iRnd >= 70 and iRnd < 80:
#		caster.cast(gc.getInfoTypeForString('SPELL_BURNING_BLOOD'))
#	if iRnd >= 80 and iRnd < 90:
#		caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DEMON'), True)
#	if iRnd >= 90:
#		caster.kill(True, 0)

#def reqRebuildBarnaxus(caster):
#	pPlot = caster.plot()
#	pCity = pPlot.getPlotCity()
#	pPlayer = gc.getPlayer(pCity.getOwner())
#	if caster.getUnitType() == gc.getInfoTypeForString('UNIT_BARNAXUS'):
#		return False
#	if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
#		return False
#	bValid = False
#	for i in range(pPlot.getNumUnits()):
#		pUnit = pPlot.getUnit(i)
#		if pUnit.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
#			bValid = True
#	if bValid == False:
#		return False
#	return True

#def spellRebuildBarnaxus(caster):
#	pPlot = caster.plot()
#	pCity = pPlot.getPlotCity()
#	pPlayer = gc.getPlayer(pCity.getOwner())
#	newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_BARNAXUS'), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#	newUnit.setDamage(75, caster.getOwner())
#	newUnit.finishMoves()
#	caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_PIECES_OF_BARNAXUS'), False)

#def spellRecruit(caster):
#	pPlot = caster.plot()
#	pCity = pPlot.getPlotCity()
#	pPlayer = gc.getPlayer(caster.getOwner())
#	eTeam = gc.getTeam(pPlayer.getTeam())
#	iLoop = (pCity.getPopulation() / 3) + 1
#	if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_OF_THE_ORDER')) == 1:
#		iLoop = iLoop * 2
#	for i in range(iLoop):
#		iRnd = CyGame().getSorenRandNum(60, "Bob")
#		iUnit = -1
#		if iRnd <= 10:
#			iUnit = gc.getInfoTypeForString('UNITCLASS_SCOUT')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_HUNTING')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_HUNTER')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_ANIMAL_HANDLING')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_RANGER')
#		elif iRnd <= 20:
#			iUnit = gc.getInfoTypeForString('UNITCLASS_SCOUT')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_HUNTING')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_HUNTER')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_POISONS')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_ASSASSIN')
#		elif iRnd <= 30:
#			iUnit = gc.getInfoTypeForString('UNITCLASS_SCOUT')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_HORSEBACK_RIDING')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_HORSEMAN')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_STIRRUPS')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_HORSE_ARCHER')
#		elif iRnd <= 40:
#			iUnit = gc.getInfoTypeForString('UNITCLASS_SCOUT')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_HORSEBACK_RIDING')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_HORSEMAN')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_TRADE')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_CHARIOT')
#		elif iRnd <= 50:
#			iUnit = gc.getInfoTypeForString('UNITCLASS_WARRIOR')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_BRONZE_WORKING')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_AXEMAN')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_IRON_WORKING')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_CHAMPION')
#		elif iRnd <= 60:
#			iUnit = gc.getInfoTypeForString('UNITCLASS_WARRIOR')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_ARCHERY')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_ARCHER')
#			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_BOWYERS')):
#				iUnit = gc.getInfoTypeForString('UNITCLASS_LONGBOWMAN')
#		if iUnit != -1:
#			infoCiv = gc.getCivilizationInfo(pPlayer.getCivilizationType())
#			iUnit = infoCiv.getCivilizationUnits(iUnit)
#			if iUnit != -1:
#				newUnit = pPlayer.initUnit(iUnit, caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#	caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_RECRUITER'), False)
#	if caster.getUnitType() != gc.getInfoTypeForString('UNIT_DONAL'):
#		caster.kill(True, 0)

def reqRecruitMercenary(caster):
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	if pCity.isHasCorporation(gc.getInfoTypeForString('CORPORATION_FIGHTERSGUILD')) == False:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BRETONNIA'):
			return False
		iX = caster.getX()
		iY = caster.getY()
		eTeam = gc.getTeam(pPlayer.getTeam())
		for iiX in range(iX-1, iX+2, 1):
			for iiY in range(iY-1, iY+2, 1):
				pPlot = CyMap().plot(iiX,iiY)
				for i in range(pPlot.getNumUnits()):
					pUnit = pPlot.getUnit(i)
					p2Player = gc.getPlayer(pUnit.getOwner())
					e2Team = p2Player.getTeam()
					if eTeam.isAtWar(e2Team) == True:
						return True
		return False
	return True

def spellRecruitMercenary(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	iUnit = gc.getInfoTypeForString('UNITCLASS_MERCENARY')
	infoCiv = gc.getCivilizationInfo(pPlayer.getCivilizationType())
	iUnit = infoCiv.getCivilizationUnits(iUnit)
	newUnit = pPlayer.initUnit(iUnit, caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
	newUnit.finishMoves()
	newUnit.setHasCasted(True)

def reqRepair(caster):
	pPlot = caster.plot()
	iGolem = gc.getInfoTypeForString('PROMOTION_GOLEM')
	iNaval = gc.getInfoTypeForString('UNITCOMBAT_NAVAL')
	iSiege = gc.getInfoTypeForString('UNITCOMBAT_SIEGE')
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if (pUnit.getUnitCombatType() == iSiege or pUnit.getUnitCombatType() == iNaval or pUnit.isHasPromotion(iGolem)):
			if pUnit.getDamage() > 0:
				return True
	return False

def spellRepair(caster,amount):
	pPlot = caster.plot()
	iGolem = gc.getInfoTypeForString('PROMOTION_GOLEM')
	iNaval = gc.getInfoTypeForString('UNITCOMBAT_NAVAL')
	iSiege = gc.getInfoTypeForString('UNITCOMBAT_SIEGE')
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if (pUnit.getUnitCombatType() == iSiege or pUnit.getUnitCombatType() == iNaval or pUnit.isHasPromotion(iGolem)):
			pUnit.changeDamage(-amount,0)

#def reqRessurection(caster):
#	pPlot = caster.plot()
#	if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_GRAVEYARD'):
#		return True
#	pPlayer = gc.getPlayer(caster.getOwner())
#	iHero = cf.getHero(pPlayer)
#	if iHero == -1:
#		return False
#	if CyGame().isUnitClassMaxedOut(iHero, 0) == False:
#		return False
#	if pPlayer.getUnitClassCount(iHero) > 0:
#		return False
#	return True

#def spellRessurection(caster):
#	pPlot = caster.plot()
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_GRAVEYARD'):
#		infoCiv = gc.getCivilizationInfo(pPlayer.getCivilizationType())
#		iUnit = infoCiv.getCivilizationUnits(gc.getInfoTypeForString('UNITCLASS_CHAMPION'))
#		if iUnit != -1:
#			newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#			newUnit.changeExperience(CyGame().getSorenRandNum(30, "Flames Spread"), -1, False, False, False)
#		pPlot.setImprovementType(-1)
#	else:
#		iHero = cf.getHero(pPlayer)
#		infoCiv = gc.getCivilizationInfo(pPlayer.getCivilizationType())
#		iUnit = infoCiv.getCivilizationUnits(iHero)
#		newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
#		CyInterface().addMessage(caster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_HERO_RESSURECTED", ()),'AS2D_CHARM_PERSON',1,'Art/Interface/Buttons/Spells/Ressurection.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)

def reqRevelry(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isGoldenAge():
		return False
	if pPlayer.isHuman() == False:
		if pPlayer.getTotalPopulation() < 25:
			return False
	return True

def spellRevelry(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	pPlayer.changeGoldenAgeTurns(CyGame().goldenAgeLength() * 2)

def reqRevelation(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	iX = caster.getX()
	iY = caster.getY()
	iHidden = gc.getInfoTypeForString('PROMOTION_HIDDEN')
	iHiddenNationality = gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY')
	iIllusion = gc.getInfoTypeForString('PROMOTION_ILLUSION')
	iInvisible = gc.getInfoTypeForString('PROMOTION_INVISIBLE')
	for iiX in range(iX-3, iX+4, 1):
		for iiY in range(iY-3, iY+4, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for iUnit in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(iUnit)
				if pUnit.getTeam() != iTeam:
					if pUnit.isHasPromotion(iHidden):
						return True
					if pUnit.isHasPromotion(iHiddenNationality):
						return True
					if pUnit.isHasPromotion(iInvisible):
						return True
					if pUnit.isHasPromotion(iIllusion):
						return True
	return False

def spellRevelation(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	iTeam = pPlayer.getTeam()
	iX = caster.getX()
	iY = caster.getY()
	iHidden = gc.getInfoTypeForString('PROMOTION_HIDDEN')
	iHiddenNationality = gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY')
	iIllusion = gc.getInfoTypeForString('PROMOTION_ILLUSION')
	iInvisible = gc.getInfoTypeForString('PROMOTION_INVISIBLE')
	for iiX in range(iX-3, iX+4, 1):
		for iiY in range(iY-3, iY+4, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for iUnit in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(iUnit)
				if pUnit.getTeam() != iTeam:
					if pUnit.isHasPromotion(iHidden):
						pUnit.setHasPromotion(iHidden, False)
					if pUnit.isHasPromotion(iHiddenNationality):
						pUnit.setHasPromotion(iHiddenNationality, False)
					if pUnit.isHasPromotion(iInvisible):
						pUnit.setHasPromotion(iInvisible, False)
					if pUnit.isHasPromotion(iIllusion):
						pUnit.kill(True, 0)

def spellRingofFlames(caster):
	iX = caster.getX()
	iY = caster.getY()
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			if not (iiX == iX and iiY == iY):
				pPlot = CyMap().plot(iiX,iiY)
				if (pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_JUNGLE') or pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FOREST_NEW')):
					if CyGame().getSorenRandNum(100, "Flames Spread") <= gc.getDefineINT('FLAMES_SPREAD_CHANCE'):
						pPlot.setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_SMOKE'))

def reqRiverOfBlood(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.getNumCities() == 0:
		return False
	if pPlayer.isHuman() == False:
		if pPlayer.getNumCities() < 5:
			return False
	return True

#def spellRiverOfBlood(caster):
#	iCalabim = gc.getInfoTypeForString('CIVILIZATION_CALABIM')
#	for iPlayer in range(gc.getMAX_PLAYERS()):
#		pPlayer = gc.getPlayer(iPlayer)
#		if pPlayer.isAlive():
#			if pPlayer.getCivilizationType() != iCalabim:
#				for iCity in range(pPlayer.getNumCities()):
#					pCity = pPlayer.getCity(iCity)
#					if pCity.getPopulation() > 2:
#						pCity.changePopulation(-2)
#			if pPlayer.getCivilizationType() == iCalabim:
#				for iCity in range(pPlayer.getNumCities()):
#					pCity = pPlayer.getCity(iCity)
#					pCity.changePopulation(2)

def reqRoar(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	iX = caster.getX()
	iY = caster.getY()
	iDragon = gc.getInfoTypeForString('PROMOTION_CULT_OF_THE_DRAGON')
	iTarget = -1
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if (pUnit.getTeam() != caster.getTeam() and pUnit.isHasPromotion(iDragon)):
					iTarget = iTarget + 1
	if iTarget == -1:
		return False
	return True

def spellRoar(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	iX = caster.getX()
	iY = caster.getY()
	iDragon = gc.getInfoTypeForString('PROMOTION_CULT_OF_THE_DRAGON')
	iLoyalty = gc.getInfoTypeForString('PROMOTION_LOYALTY')
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if (pUnit.getTeam() != caster.getTeam() and pUnit.isHasPromotion(iDragon)):
					if pUnit.isHasPromotion(iLoyalty):
						pUnit.kill(True, 0)
					else:
						newUnit = pPlayer.initUnit(pUnit.getUnitType(), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
						newUnit.convert(pUnit)

#def reqRobGrave(caster):
#	pPlot = caster.plot()
#	if pPlot.getImprovementType() != gc.getInfoTypeForString('IMPROVEMENT_GRAVEYARD'):
#		return False
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.isHuman() == False:
#		if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
#			return False
#	return True

#def spellRobGrave(caster):
#	CyGame().changeGlobalCounter(1)
#	pPlot = caster.plot()
#	pPlot.setImprovementType(-1)
#	pPlayer = gc.getPlayer(caster.getOwner())
#	iRnd = CyGame().getSorenRandNum(100, "Rob Grave")
#	if iRnd < 20:
#		pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_GRAVE_LOW_GOLD'), caster)
#	if iRnd >= 20 and iRnd < 40:
#		pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_GRAVE_HIGH_GOLD'), caster)
#	if iRnd >= 40 and iRnd < 60:
#		pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_GRAVE_TECH'), caster)
#	if iRnd >= 60 and iRnd < 80:
#		pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_GRAVE_SKELETONS'), caster)
#	if iRnd >= 80:
#		pPlayer.receiveGoody(pPlot, gc.getInfoTypeForString('GOODY_GRAVE_SPECTRE'), caster)

def reqSacrifice(caster):
	if caster.getDuration() != 0:
		return false
	pPlot = caster.plot()
	if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_PYRE_OF_THE_SERAPHIC'):
		if caster.getRace() == gc.getInfoTypeForString('PROMOTION_ANGEL'):
			return true
	if pPlot.isCity() == false:
		return false
	if pPlot.getPlotCity().getNumBuilding(gc.getInfoTypeForString('BUILDING_DEMONS_ALTAR')) == 0:
		return False
	if caster.getLevel() < 2:
		return False
	if caster.isAlive() == False:
		return False
	return True

def spellSacrifice(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	pPlot = caster.plot()
	eTeam = gc.getTeam(pPlayer.getTeam())
	iTech = pPlayer.getCurrentResearch()
	iNum = 10 + (caster.getLevel() * caster.getLevel())
	eTeam.changeResearchProgress(iTech, iNum, caster.getOwner())
	if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_PYRE_OF_THE_SERAPHIC'):
		if caster.getRace() == gc.getInfoTypeForString('PROMOTION_ANGEL'):
			caster.cast(gc.getInfoTypeForString('SPELL_RING_OF_FLAMES'))
			iCount = 1
			if isWorldUnitClass(caster.getUnitClassType()):
				iCount = 7
			for i in range(iCount):
				newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_FIRE_ELEMENTAL'), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)

def reqSanctuary(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		iTeam = gc.getPlayer(caster.getOwner()).getTeam()
		eTeam = gc.getTeam(iTeam)
		if eTeam.getAtWarCount(True) < 2:
			return False
	return True

def spellSanctuary(caster):
	iPlayer = caster.getOwner()
	iTeam = caster.getTeam()
	pPlayer = gc.getPlayer(iPlayer)
	pPlayer.changeSanctuaryTimer(30)
	for i in range (CyMap().numPlots()):
		pPlot = CyMap().plotByIndex(i)
		if pPlot.isOwned():
			if pPlot.getOwner() == iPlayer:
				for i in range(pPlot.getNumUnits(), -1, -1):
					pUnit = pPlot.getUnit(i)
					if pUnit.getTeam() != iTeam:
						pUnit.jumpToNearestValidPlot()

def reqSandLion(caster):
	pPlot = caster.plot()
	if (pPlot.getTerrainType() != gc.getInfoTypeForString('TERRAIN_DESERT') and pPlot.getTerrainType() != gc.getInfoTypeForString('TERRAIN_BURNING_SANDS')):
		return False
	return True

def reqScorch(caster):
	pPlot = caster.plot()
	pPlayer = gc.getPlayer(caster.getOwner())
	if (pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_PLAINS') or pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_FIELDS_OF_PERDITION')):
		if pPlayer.isHuman() == False:
			if caster.getOwner() == pPlot.getOwner():
				return False
		return True
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_SNOW'):
		if pPlayer.isHuman() == False:
			if caster.getOwner() != pPlot.getOwner():
				return False
			if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
				return False
			if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_ILLIANS'):
				return False
		return True	
	return False

def spellScorch(caster):
	pPlot = caster.plot()
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_PLAINS'):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_DESERT'),True,True)
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_FIELDS_OF_PERDITION'):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_BURNING_SANDS'),True,True)
	if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_SNOW'):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_TUNDRA'),True,True)
	if pPlot.isOwned():
		startWar(caster.getOwner(), pPlot.getOwner())

def spellSing(caster):
	pPlot = caster.plot()
	point = pPlot.getPoint()
	iRnd = CyGame().getSorenRandNum(100, "Sing")
	szText = "AS3D_SING1"
	if iRnd > 25:
		szText = "AS3D_SING2"
	if iRnd > 50:
		szText = "AS3D_SING3"
	if iRnd > 75:
		szText = "AS3D_SING4"
	CyAudioGame().Play3DSound(szText,point.x,point.y,point.z)

def reqShallyasTouch(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.getBuildingClassCount(gc.getInfoTypeForString('BUILDINGCLASS_SISTERS_OF_SHALLYA')) == 0:
		return False
	if caster.isAlive() == False:
		return False
	if caster.getDamage() == 0:
		return False
	if pPlayer.isFeatAccomplished(FeatTypes.FEAT_HEAL_UNIT_PER_TURN) == false:
		return False
	if pPlayer.isHuman() == False:
		if caster.getDamage() < 15:
			return False
	return True

def spellShallyasTouch(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	pPlayer.setFeatAccomplished(FeatTypes.FEAT_HEAL_UNIT_PER_TURN, false)
	caster.changeDamage(-15,0)

def reqSlaveTrade(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isSlaveTrade() == False:
		return False
	return True

def spellSlaveTradeBuy(caster):
	pCity = caster.plot().getPlotCity()
	pPlayer = gc.getPlayer(caster.getOwner())
	pPlot = caster.plot()
	iRnd = CyGame().getSorenRandNum(100, "Slave Trade Buy")
	if (iRnd < 60):
		iUnit = gc.getInfoTypeForString('UNIT_SLAVE')
	if (iRnd >= 60 and iRnd < 70):
		iUnit = gc.getInfoTypeForString('UNIT_SLAVE_DWARF')
	if (iRnd >= 70 and iRnd < 80):
		iUnit = gc.getInfoTypeForString('UNIT_SLAVE_ELF')
	if (iRnd >= 80):
		iUnit = gc.getInfoTypeForString('UNIT_SLAVE_ORC')
	newUnit = pPlayer.initUnit(iUnit, pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)

#def reqSpreadTheCouncilOfEsus(caster):
#	pPlayer = gc.getPlayer(caster.getOwner())
#	pCity = caster.plot().getPlotCity()
#	if pCity.isHasReligion(gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS')):
#		return False
#	if pPlayer.isHuman() == False:
#		if pPlayer.getStateReligion() != gc.getInfoTypeForString('RELIGION_COUNCIL_OF_ESUS'):
#			return False
#	return True

def reqSpring(caster):
	pPlot = caster.plot()
	pPlayer = gc.getPlayer(caster.getOwner())
	bFlames = false
	iX = pPlot.getX()
	iY = pPlot.getY()
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot2 = CyMap().plot(iiX,iiY)
			if pPlot2.getFeatureType() == gc.getInfoTypeForString('FEATURE_FLAMES') or pPlot2.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_SMOKE'):
				bFlames = true
	if bFlames == False:
		if pPlot.getTerrainType() != gc.getInfoTypeForString('TERRAIN_DESERT'):
			return False
		if pPlot.getFeatureType() == gc.getInfoTypeForString('FEATURE_FLOOD_PLAINS'):
			return False
		if pPlayer.isHuman() == False:
			if caster.getOwner() != pPlot.getOwner():
				return False
	if pPlayer.isHuman() == False:
		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_INFERNAL'):
			return False
	return True

def spellSpring(caster):
	pPlot = caster.plot()
	if (pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_DESERT') and pPlot.getFeatureType() != gc.getInfoTypeForString('FEATURE_FLOOD_PLAINS')):
		pPlot.setTerrainType(gc.getInfoTypeForString('TERRAIN_PLAINS'),True,True)
	iX = pPlot.getX()
	iY = pPlot.getY()
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot2 = CyMap().plot(iiX,iiY)
			if pPlot2.getFeatureType() == gc.getInfoTypeForString('FEATURE_FLAMES'):
				pPlot2.setFeatureType(-1, -1)
			if pPlot2.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_SMOKE'):
				pPlot2.setImprovementType(-1)

def reqSteal(caster):
	iTeam = caster.getTeam()
	pPlot = caster.plot()
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if pUnit.getTeam() != iTeam:
			for iProm in range(gc.getNumPromotionInfos()):
				if pUnit.isHasPromotion(iProm):
					if gc.getPromotionInfo(iProm).isEquipment():
						return True
	if pPlot.isCity():
		pCity = pPlot.getPlotCity()
		if pCity.getTeam() != iTeam:
			for iBuild in range(gc.getNumBuildingInfos()):
				if pCity.getNumRealBuilding(iBuild) > 0:
					if gc.getPromotionInfo(iBuild).isEquipment():
						return True
	return False

def spellSteal(caster):
	iTeam = caster.getTeam()
	pPlot = caster.plot()
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if pUnit.getTeam() != iTeam:
			for iProm in range(gc.getNumPromotionInfos()):
				if pUnit.isHasPromotion(iProm):
					if gc.getPromotionInfo(iProm).isEquipment():
 						if CyGame().getSorenRandNum(100, "Steal") <= 20:
							startWar(caster.getOwner(), pUnit.getOwner())
						else:
							caster.setHasPromotion(iProm, True)
							pUnit.setHasPromotion(iProm, False)
	if pPlot.isCity():
		pCity = pPlot.getPlotCity()
		if pCity.getTeam() != iTeam:
			for iBuild in range(gc.getNumBuildingInfos()):
				if pCity.getNumRealBuilding(iBuild) > 0:
					if gc.getBuildingInfo(iBuild).isEquipment():
 						if CyGame().getSorenRandNum(100, "Steal") <= 20:
							startWar(caster.getOwner(), pUnit.getOwner())
						else:
							for iUnit in range(gc.getNumUnitInfos()):
								if gc.getUnitInfo(iUnit).getBuildings(i):
									pCity.setNumRealBuilding(iBuild, 0)
									caster.setHasPromotion(gc.getUnitInfo(iUnit).getEquipmentPromotion(), True)

def reqSubmerg(caster):
	if caster.isMadeAttack():
		return False
	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN')):
		return False
	pPlot = caster.plot()
	if pPlot.isWater() == False:
		return False
	return True
	
def reqSummonTreant(caster):
	pPlot = caster.plot()
	if (pPlot.getFeatureType() != gc.getInfoTypeForString('FEATURE_FOREST') and pPlot.getFeatureType() != gc.getInfoTypeForString('FEATURE_FOREST_ANCIENT')):
		return False
	return True

def reqTakeEquipment(caster,unit):
	if caster.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_NAVAL'):
		return False
	if caster.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_SIEGE'):
		return False
	if caster.getSpecialUnitType() == gc.getInfoTypeForString('SPECIALUNIT_SPELL'):
		return False
	if caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ILLUSION')):
		return False
	iUnit = gc.getInfoTypeForString(unit)
	iProm = gc.getUnitInfo(iUnit).getEquipmentPromotion()
	if caster.isHasPromotion(iProm):
		return False
	iPlayer = caster.getOwner()
	pPlayer = gc.getPlayer(iPlayer)
	pPlot = caster.plot()
	pHolder = -1
	bValid = False
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if (pUnit.getOwner() == iPlayer and pUnit.isHasPromotion(iProm)):
			pHolder = pUnit
			bValid = True
		if (pUnit.getOwner() == iPlayer and pUnit.getUnitType() == iUnit):
			if pUnit.isDelayedDeath() == False:
				pHolder = pUnit
				bValid = True
	if pPlot.isCity():
		if pPlot.getPlotCity().getOwner() == iPlayer:
			for i in range(gc.getNumBuildingInfos()):
				if gc.getUnitInfo(iUnit).getBuildings(i):
					if pPlot.getPlotCity().getNumRealBuilding(i) > 0:
						bValid = True
	if bValid == False:
		return False
	if pHolder != -1:
		if pHolder.getUnitType() == gc.getInfoTypeForString('UNIT_BARNAXUS'):
			if iProm == gc.getInfoTypeForString('PROMOTION_PIECES_OF_BARNAXUS'):
				return False
		if pHolder.isHasCasted():
			return False
	if pPlayer.isHuman() == False:
		if pHolder == -1:
			return False
		if caster.baseCombatStr() - 2 <= pHolder.baseCombatStr():
			return False
	return True

def spellTakeEquipment(caster,unit):
	iUnit = gc.getInfoTypeForString(unit)
	iProm = gc.getUnitInfo(iUnit).getEquipmentPromotion()
	iPlayer = caster.getOwner()
	pPlot = caster.plot()
	bValid = False
	pHolder = -1
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if (pUnit.getOwner() == iPlayer and pUnit.isHasPromotion(iProm)):
			pHolder = pUnit
			bValid = True
		if (pUnit.getOwner() == iPlayer and pUnit.getUnitType() == iUnit):
			if pUnit.isDelayedDeath() == False:
				pHolder = pUnit
				bValid = True
	if pHolder != -1:
		if pHolder.getUnitType() == iUnit:
			pHolder.kill(True, 0)
		else:
			pHolder.setHasPromotion(iProm, False)
	if pPlot.isCity():
		if pPlot.getPlotCity().getOwner() == iPlayer:
			for i in range(gc.getNumBuildingInfos()):
				if gc.getUnitInfo(iUnit).getBuildings(i):
					pPlot.getPlotCity().setNumRealBuilding(i, 0)
					bValid = True
	if bValid:
		caster.setHasPromotion(iProm, True)

def spellTeleport(caster,loc):
	player = caster.getOwner()
	pPlayer = gc.getPlayer(player)
	pCity = pPlayer.getCapitalCity()
	caster.setXY(pCity.getX(), pCity.getY(), false, true, true)

def reqTrain(caster,promotion):
	iAnimal = gc.getInfoTypeForString('UNITCOMBAT_ANIMAL')
	iPromotion = gc.getInfoTypeForString(promotion)
	pPlot = caster.plot()
	pPlayer = gc.getPlayer(caster.getOwner())
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if (pUnit.getOwner() == caster.getOwner() and pUnit.isHasPromotion(iPromotion) == False):
			if (pUnit.getUnitCombatType() != iAnimal and pUnit.isAlive()):
				return True
	return False

def spellTrain(caster,promotion):
	iPromotion = gc.getInfoTypeForString(promotion)
	iAnimal = gc.getInfoTypeForString('UNITCOMBAT_ANIMAL')
	iChanneling1 = gc.getInfoTypeForString('PROMOTION_CHANNELING1')
	pPlot = caster.plot()
	pPlayer = gc.getPlayer(caster.getOwner())
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if pUnit.getOwner() == caster.getOwner():
			if (pUnit.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_ANIMAL') and pUnit.isAlive()):
				pUnit.setHasPromotion(iPromotion, True)
				pUnit.setHasPromotion(iChanneling1, True)

def reqTreetopDefence(caster):
	pPlot = caster.plot()
	if (pPlot.getFeatureType() != gc.getInfoTypeForString('FEATURE_FOREST') and pPlot.getFeatureType() != gc.getInfoTypeForString('FEATURE_FOREST_ANCIENT')):
		return False
	return True

def spellTreetopDefence(caster):
	pPlot = caster.plot()
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
		if pUnit.getTeam() == caster.getTeam():
			pUnit.setFortifyTurns(5)

def reqTrust(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isFeatAccomplished(FeatTypes.FEAT_TRUST):
		return False
	if pPlayer.isBarbarian():
		return False
	return True

def spellTrust(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	pCity = pPlayer.getCapitalCity()
	pPlayer.setFeatAccomplished(FeatTypes.FEAT_TRUST, true)

def spellTsunami(caster):
	iX = caster.getX()
	iY = caster.getY()
	for iiX in range(iX-2, iX+3, 1):
		for iiY in range(iY-2, iY+3, 1):
			pPlot = CyMap().plot(iiX,iiY)
			if pPlot.isAdjacentToWater():
				if (iX != iiX or iY != iiY):
					for i in range(pPlot.getNumUnits()):
						pUnit = pPlot.getUnit(i)
						pUnit.doDamage(50, 75, caster, gc.getInfoTypeForString('DAMAGE_COLD'), true)
					if pPlot.getImprovementType() != -1:
						if CyGame().getSorenRandNum(100, "Tsunami") <= 25:
							pPlot.setImprovementType(-1)
					CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SPRING'),pPlot.getPoint())

def reqUnyieldingOrder(caster):
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_UNYIELDING_ORDER')) > 0:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == false:
		if pCity.getOwner() != caster.getOwner():
			return False
	return True

def spellUnyieldingOrder(caster):
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	pCity.setOccupationTimer(0)
	pCity.changeHurryAngerTimer(-9)

def reqVeilOfNight(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		if pPlayer.getNumUnits() < 25:
			return False
		iTeam = gc.getPlayer(caster.getOwner()).getTeam()
		eTeam = gc.getTeam(iTeam)
		if eTeam.getAtWarCount(True) > 0:
			return False
	return True

def spellVeilOfNight(caster):
	iHiddenNationality = gc.getInfoTypeForString('PROMOTION_HIDDEN_NATIONALITY')
	py = PyPlayer(caster.getOwner())
	for pUnit in py.getUnitList():
		if pUnit.baseCombatStr() > 0:
			pUnit.setHasPromotion(iHiddenNationality, True)

def reqWane(caster):
	if caster.getLevel() < 6:
		return False
	if caster.isAlive() == False:
		return False
	if caster.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ANIMAL'):
		return False
	if caster.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_BEAST'):
		return False
#	pPlayer = gc.getPlayer(caster.getOwner())
#	if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_SHADE')) >= 4:
#		return False
	return True

def reqWarcry(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		if pPlayer.getNumUnits() < 25:
			return False
		iTeam = gc.getPlayer(caster.getOwner()).getTeam()
		eTeam = gc.getTeam(iTeam)
		if eTeam.getAtWarCount(True) == 0:
			return False
	return True

def spellWarcry(caster):
	iWarcry = gc.getInfoTypeForString('PROMOTION_WARCRY')
	py = PyPlayer(caster.getOwner())
	for pUnit in py.getUnitList():
		if pUnit.getUnitCombatType() != -1:
			pUnit.setHasPromotion(iWarcry, True)

def reqWildHunt(caster):
	iPlayer = caster.getOwner()
	pPlayer = gc.getPlayer(iPlayer)
	if pPlayer.isHuman() == False:
		iTeam = gc.getPlayer(iPlayer).getTeam()
		eTeam = gc.getTeam(iTeam)
		if eTeam.getAtWarCount(True) == 0:
			return False
		if pPlayer.getNumUnits() < 20:
			return False
	return True

def spellWildHunt(caster):
	iWolf = gc.getInfoTypeForString('UNIT_WOLF')
	pPlayer = gc.getPlayer(caster.getOwner())
	py = PyPlayer(caster.getOwner())
	for pUnit in py.getUnitList():
		if pUnit.baseCombatStr() > 0:
			newUnit = pPlayer.initUnit(iWolf, pUnit.getX(), pUnit.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
			if pUnit.baseCombatStr() > 3:
				i = (pUnit.baseCombatStr() - 2) / 2
				newUnit.setBaseCombatStr(2 + i)

#def spellWonder(caster):
#	iCount = CyGame().getSorenRandNum(3, "Wonder") + 3
#	pPlayer = gc.getPlayer(caster.getOwner())
#	pPlot = caster.plot()
#	bCity = False
#	point = pPlot.getPoint()
#	if pPlot.isCity():
#		bCity = True
#	for i in range (iCount):
#		iRnd = CyGame().getSorenRandNum(63, "Wonder")
#		if iRnd == 0:
#			caster.cast(gc.getInfoTypeForString('SPELL_BLAZE'))
#		if iRnd == 1:
#			caster.cast(gc.getInfoTypeForString('SPELL_BLESS'))
#		if iRnd == 2:
#			caster.cast(gc.getInfoTypeForString('SPELL_BLINDING_LIGHT'))
#		if iRnd == 3:
#			caster.cast(gc.getInfoTypeForString('SPELL_BLOOM'))
#		if iRnd == 4:
#			caster.cast(gc.getInfoTypeForString('SPELL_BLUR'))
#		if iRnd == 5:
#			caster.cast(gc.getInfoTypeForString('SPELL_CHARM_PERSON'))
#		if iRnd == 6:
#			caster.cast(gc.getInfoTypeForString('SPELL_CONTAGION'))
#		if iRnd == 7:
#			caster.cast(gc.getInfoTypeForString('SPELL_COURAGE'))
#		if iRnd == 8:
#			caster.cast(gc.getInfoTypeForString('SPELL_CRUSH'))
#		if iRnd == 9:
#			caster.cast(gc.getInfoTypeForString('SPELL_DESTROY_UNDEAD'))
#		if iRnd == 10:
#			caster.cast(gc.getInfoTypeForString('SPELL_DISPEL_MAGIC'))
#		if iRnd == 11:
#			caster.cast(gc.getInfoTypeForString('SPELL_EARTHQUAKE'))
#		if iRnd == 12:
#			caster.cast(gc.getInfoTypeForString('SPELL_ENCHANTED_BLADE'))
#		if iRnd == 13:
#			CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SPELL1'),point)
#			CyAudioGame().Play3DSound("AS3D_SPELL_DEFILE",point.x,point.y,point.z)
#			for iX in range(pPlot.getX()-1, pPlot.getX()+2, 1):
#				for iY in range(pPlot.getY()-1, pPlot.getY()+2, 1):
#					pLoopPlot = CyMap().plot(iX,iY)
#					if pLoopPlot.isNone() == False:
#						pLoopPlot.changePlotCounter(100)
#		if iRnd == 14:
#			caster.cast(gc.getInfoTypeForString('SPELL_ENTANGLE'))
#		if iRnd == 15:
#			caster.cast(gc.getInfoTypeForString('SPELL_ESCAPE'))
#		if iRnd == 16:
#			caster.cast(gc.getInfoTypeForString('SPELL_FIREBALL'))
#		if iRnd == 17:
#			caster.cast(gc.getInfoTypeForString('SPELL_FLAMING_ARROWS'))
#		if iRnd == 18:
#			caster.cast(gc.getInfoTypeForString('SPELL_FLOATING_EYE'))
#		if iRnd == 19:
#			caster.cast(gc.getInfoTypeForString('SPELL_HASTE'))
#		if iRnd == 20:
#			caster.cast(gc.getInfoTypeForString('SPELL_HASTURS_RAZOR'))
#		if iRnd == 21:
#			caster.cast(gc.getInfoTypeForString('SPELL_HEAL'))
#		if iRnd == 22:
#			caster.cast(gc.getInfoTypeForString('SPELL_HIDE'))
#		if iRnd == 23:
#			caster.cast(gc.getInfoTypeForString('SPELL_LOYALTY'))
#		if iRnd == 24:
#			caster.cast(gc.getInfoTypeForString('SPELL_MAELSTROM'))
#		if iRnd == 25:
#			caster.cast(gc.getInfoTypeForString('SPELL_MORALE'))
#		if iRnd == 26:
#			caster.cast(gc.getInfoTypeForString('SPELL_MUTATION'))
#		if iRnd == 27:
#			caster.cast(gc.getInfoTypeForString('SPELL_PILLAR_OF_FIRE'))
#		if iRnd == 28:
#			caster.cast(gc.getInfoTypeForString('SPELL_POISONED_BLADE'))
#		if iRnd == 29:
#			caster.cast(gc.getInfoTypeForString('SPELL_REVELATION'))
#		if iRnd == 30:
#			caster.cast(gc.getInfoTypeForString('SPELL_RING_OF_FLAMES'))
#		if iRnd == 31:
#			caster.cast(gc.getInfoTypeForString('SPELL_RUST'))
#		if iRnd == 32:
#			caster.cast(gc.getInfoTypeForString('SPELL_SANCTIFY'))
#		if iRnd == 33:
#			caster.cast(gc.getInfoTypeForString('SPELL_SCORCH'))
#		if iRnd == 34:
#			caster.cast(gc.getInfoTypeForString('SPELL_SHADOWWALK'))
#		if iRnd == 35:
#			caster.cast(gc.getInfoTypeForString('SPELL_SPORES'))
#		if iRnd == 36:
#			caster.cast(gc.getInfoTypeForString('SPELL_SPRING'))
#		if iRnd == 37:
#			caster.cast(gc.getInfoTypeForString('SPELL_STONESKIN'))
#		if iRnd == 38:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_AIR_ELEMENTAL'))
#		if iRnd == 39:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_AUREALIS'))
#		if iRnd == 40:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_BALOR'))
#		if iRnd == 41:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_DJINN'))
#		if iRnd == 42:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_EARTH_ELEMENTAL'))
#		if iRnd == 43:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_EINHERJAR'))
#		if iRnd == 44:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_FIRE_ELEMENTAL'))
#		if iRnd == 45:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_KRAKEN'))
#		if iRnd == 46:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_MISTFORM'))
#		if iRnd == 47:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_PIT_BEAST'))
#		if iRnd == 48:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_SAND_LION'))
#		if iRnd == 49:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_SPECTRE'))
#		if iRnd == 50:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_TIGER'))
#		if iRnd == 51:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_TREANT'))
#		if iRnd == 52:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_WATER_ELEMENTAL'))
#		if iRnd == 53:
#			caster.cast(gc.getInfoTypeForString('SPELL_SUMMON_WRAITH'))
#		if iRnd == 54:
#			caster.cast(gc.getInfoTypeForString('SPELL_TSUNAMI'))
#		if iRnd == 55:
#			caster.cast(gc.getInfoTypeForString('SPELL_VALOR'))
#		if iRnd == 56:
#			caster.cast(gc.getInfoTypeForString('SPELL_VITALIZE'))
#		if iRnd == 57:
#			caster.cast(gc.getInfoTypeForString('SPELL_WITHER'))
#		if iRnd == 58:
#			if bCity == False:
#				pPlot.setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_PENGUINS'))
#				CyInterface().addMessage(caster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_WONDER_PENGUINS", ()),'',1,'Art/Interface/Buttons/Improvements/Penguins.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
#		if iRnd == 59:
#			if bCity == False:
#				pPlot.setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_MUSHROOMS'))
#				CyInterface().addMessage(caster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_WONDER_MUSHROOMS", ()),'',1,'Art/Interface/Buttons/Improvements/Mushrooms.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
#		if iRnd == 60:
#			for iProm in range(gc.getNumPromotionInfos()):
#				if caster.isHasPromotion(iProm):
#					if gc.getPromotionInfo(iProm).isRace():
#						caster.setHasPromotion(iProm, False)
#			caster.setUnitArtStyleType(gc.getInfoTypeForString('UNIT_ARTSTYLE_BABOON'))
#			CyInterface().addMessage(caster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_WONDER_BABOON", ()),'',1,'Art/Interface/Buttons/Units/Margalard.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
#		if iRnd == 61:
#			CyEngine().triggerEffect(gc.getInfoTypeForString('EFFECT_SPELL1'),point)
#			CyAudioGame().Play3DSound("AS3D_SPELL_SANCTIFY",point.x,point.y,point.z)
#			for iX in range(pPlot.getX()-2, pPlot.getX()+3, 1):
#				for iY in range(pPlot.getY()-2, pPlot.getY()+3, 1):
#					pLoopPlot = CyMap().plot(iX,iY)
#					if pLoopPlot.isNone() == False:
#						pLoopPlot.changePlotCounter(-100)
#		if iRnd == 62:
#			newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_SPIDERKIN'), pPlot.getX(), pPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
#			CyInterface().addMessage(caster.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_WONDER_SPIDERKIN", ()),'',1,'Art/Interface/Buttons/Units/Spiderkin.dds',ColorTypes(8),pPlot.getX(),pPlot.getY(),True,True)
#			newUnit.setDuration(3)				
				
def reqWorldbreak(caster):
	if CyGame().getGlobalCounter() == 0:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.isHuman() == False:
		if CyGame().getGlobalCounter() < 50:
			return False
	return True

def spellWorldbreak(caster):
	iCounter = CyGame().getGlobalCounter()
	iFire = gc.getInfoTypeForString('DAMAGE_FIRE')
	iForest = gc.getInfoTypeForString('FEATURE_FOREST')
	iJungle = gc.getInfoTypeForString('FEATURE_JUNGLE')
	iPillar = gc.getInfoTypeForString('EFFECT_PILLAR_OF_FIRE')
	iSmoke = gc.getInfoTypeForString('IMPROVEMENT_SMOKE')
	for i in range (CyMap().numPlots()):
		pPlot = CyMap().plotByIndex(i)
		bValid = True
		if pPlot.isOwned():
			if pPlot.getOwner() == caster.getOwner():
				bValid = False
		if bValid:
			if pPlot.isCity():
				if CyGame().getSorenRandNum(100, "Worldbreak") <= (iCounter / 4):
					cf.doCityFire(pPlot.getPlotCity())
				for i in range(pPlot.getNumUnits()):
					pUnit = pPlot.getUnit(i)
					pUnit.doDamage(iCounter, 100, caster, iFire, false)
				CyEngine().triggerEffect(iPillar,pPlot.getPoint())
			if (pPlot.getFeatureType() == iForest or pPlot.getFeatureType() == iJungle):
				if pPlot.getImprovementType() == -1:
					if CyGame().getSorenRandNum(100, "Flames Spread") <= (iCounter / 4):
						pPlot.setImprovementType(iSmoke)

def voteFundDissidents():
	iOvercouncil = gc.getInfoTypeForString('DIPLOVOTE_OVERCOUNCIL')
	for iPlayer in range(gc.getMAX_PLAYERS()):
		pPlayer = gc.getPlayer(iPlayer)
		if pPlayer.isAlive():
			if pPlayer.isFullMember(iOvercouncil):
				for iCity in range(pPlayer.getNumCities()):
					if (CyGame().getSorenRandNum(100, "Fund Dissidents") < 50):
						pCity = pPlayer.getCity(iCity)
						pCity.changeHurryAngerTimer(1 + CyGame().getSorenRandNum(3, "Fund Dissidents"))
						
def reqZombie(caster):
	if caster.getUnitClassType() != gc.getInfoTypeForString('UNITCLASS_WARRIOR'):
		return False
	pPlot = caster.plot()
	pCity = pPlot.getPlotCity()
	if pCity.getNumBuilding(gc.getInfoTypeForString('BUILDING_IMMORTALITY_TEMPLE')) == 0:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	if pPlayer.getStateReligion() != gc.getInfoTypeForString('RELIGION_IMMORTALITY'):
		return False
	return True						